The YSQL statements are compatible with the SQL dialect that PostgreSQL supports. The sidebar lists all of the YSQL statements in alphabetical order. The following tables list them by category.
Data definition language (DDL)
Statement | Description |
---|---|
ALTER DATABASE |
Change database definition |
ALTER DOMAIN |
Change domain definition |
ALTER FOREIGN DATA WRAPPER |
Change foreign data wrapper definition |
ALTER FOREIGN TABLE |
Change foreign table definition |
ALTER INDEX |
Change index definition |
ALTER MATERIALIZED VIEW |
Change materialized view definition |
ALTER PUBLICATION |
Change publication definition |
ALTER SEQUENCE |
Change sequence definition |
ALTER SERVER |
Change foreign server definition |
ALTER SCHEMA |
Change schema definition |
ALTER TABLE |
Change table definition |
COMMENT |
Set, update, or remove a comment on a database object |
CREATE AGGREGATE |
Create an aggregate |
CREATE CAST |
Create a cast |
CREATE DATABASE |
Create a database |
CREATE DOMAIN |
Create a user-defined data type with optional constraints |
CREATE EXTENSION |
Load an extension |
CREATE FOREIGN DATA WRAPPER |
Create a foreign-data wrapper |
CREATE FOREIGN TABLE |
Create a foreign table |
CREATE FUNCTION |
Create a function |
CREATE INDEX |
Create an index |
CREATE MATERIALIZED VIEW |
Create a materialized view |
CREATE OPERATOR |
Create an operator |
CREATE OPERATOR CLASS |
Create an operator class |
CREATE PROCEDURE |
Create a procedure |
CREATE PUBLICATION |
Create a publication |
CREATE RULE |
Create a rule |
CREATE SCHEMA |
Create a schema (namespace) |
CREATE SEQUENCE |
Create a sequence generator |
CREATE SERVER |
Create a foreign server |
CREATE TABLE |
Create an empty table |
CREATE TABLE AS |
Create a table from the results of a executing a SELECT |
CREATE TABLESPACE |
Create a tablespace |
CREATE TRIGGER |
Create a trigger |
CREATE TYPE |
Create a type |
CREATE USER MAPPING |
Create a user mapping |
CREATE VIEW |
Create a view |
DROP AGGREGATE |
Delete an aggregate |
DROP CAST |
Delete a cast |
DROP DATABASE |
Delete a database from the system |
DROP DOMAIN |
Delete a domain |
DROP EXTENSION |
Delete an extension |
DROP FOREIGN DATA WRAPPER |
Drop a foreign-data wrapper |
DROP FOREIGN TABLE |
Drop a foreign table |
DROP FUNCTION |
Delete a function |
DROP INDEX |
Delete an index from a database |
DROP MATERIALIZED VIEW |
Drop a materialized view |
DROP OPERATOR |
Delete an operator |
DROP OPERATOR CLASS |
Delete an operator class |
DROP PROCEDURE |
Delete a procedure |
DROP PUBLICATION |
Delete a publication |
DROP RULE |
Delete a rule |
DROP SCHEMA |
Delete a schema from the system |
DROP SEQUENCE |
Delete a sequence generator |
DROP SERVER |
Drop a foreign server |
DROP TABLE |
Delete a table from a database |
DROP TABLESPACE |
Delete a tablespace from the cluster |
DROP TYPE |
Delete a user-defined type |
DROP TRIGGER |
Delete a trigger |
IMPORT FOREIGN SCHEMA |
Import a foreign schema |
REFRESH MATERIALIZED VIEW |
Refresh a materialized view |
TRUNCATE |
Clear all rows from a table |
Data manipulation language (DML)
Statement | Description |
---|---|
CLOSE |
Remove a cursor |
DECLARE |
Create a cursor |
DELETE |
Delete rows from a table |
FETCH |
Fetch rows from a cursor |
INSERT |
Insert rows into a table |
MOVE |
Move the current position within a cursor |
SELECT |
Select rows from a table |
UPDATE |
Update rows in a table |
Data control language (DCL)
Statement | Description |
---|---|
ALTER DEFAULT PRIVILEGES |
Define default privileges |
ALTER GROUP |
Alter a group |
ALTER POLICY |
Alter a row level security policy |
ALTER ROLE |
Alter a role (user or group) |
ALTER USER |
Alter a user |
CREATE GROUP |
Create a group (role) |
CREATE POLICY |
Create a row level security policy |
CREATE ROLE |
Create a role (user or group) |
CREATE USER |
Create a user (role) |
DROP GROUP |
Drop a group |
DROP POLICY |
Drop a row level security policy |
DROP ROLE |
Drop a role (user or group) |
DROP OWNED |
Drop owned objects |
DROP USER |
Drop a user |
GRANT |
Grant permissions |
REASSIGN OWNED |
Reassign owned objects |
REVOKE |
Revoke permissions |
SET ROLE |
Set a role |
SET SESSION AUTHORIZATION |
Set session authorization |
Transaction control language (TCL)
Statement | Description |
---|---|
ABORT |
Roll back a transaction |
BEGIN |
Start a transaction |
COMMIT |
Commit a transaction |
END |
Commit a transaction |
LOCK |
Lock a table |
ROLLBACK |
Roll back a transaction |
SET CONSTRAINTS |
Set constraints on current transaction |
SET TRANSACTION |
Set transaction behaviors |
SHOW TRANSACTION |
Show properties of a transaction |
START TRANSACTION |
Start a transaction |
SAVEPOINT |
Create a new savepoint |
ROLLBACK TO |
Rollback to a savepoint |
RELEASE |
Release a savepoint |
Session and system control
Statement | Description |
---|---|
RESET |
Reset a run-time parameter to its default value |
SET |
Set the value of a run-time parameter |
SHOW |
Show the value of a run-time parameter |
Performance control
Statement | Description |
---|---|
DEALLOCATE |
Deallocate a prepared statement |
EXECUTE |
Execute a prepared statement |
EXPLAIN |
Explain an execution plan for a statement |
PREPARE |
Prepare a statement |
Streaming replication protocol statements
Statement | Description |
---|---|
CREATE_REPLICATION_SLOT |
Create a replication slot |
DROP_REPLICATION_SLOT |
Drop a replication slot |
START_REPLICATION |
Start streaming from a replication slot |