SQL Commands
Compare versions ↗Syntax, examples, and the evolution of every PostgreSQL SQL command.
| SQL Commands | Version coverage 1011121314151617181920 |
|---|---|
CLOSECursors & Prepared Statements close a cursor | 10 – 20 |
DEALLOCATECursors & Prepared Statements deallocate a prepared statement | 10 – 20 |
DECLARECursors & Prepared Statements define a cursor | 10 – 20 |
EXECUTECursors & Prepared Statements execute a prepared statement | 10 – 20 |
FETCHCursors & Prepared Statements retrieve rows from a query using a cursor | 10 – 20 |
MOVECursors & Prepared Statements position a cursor | 10 – 20 |
PREPARECursors & Prepared Statements prepare a statement for execution | 10 – 20 |
ALTER DATABASEDatabases & Schemas change a database | 10 – 20 |
ALTER SCHEMADatabases & Schemas change the definition of a schema | 10 – 20 |
ALTER TABLESPACEDatabases & Schemas change the definition of a tablespace | 10 – 20 |
CREATE DATABASEDatabases & Schemas create a new database | 10 – 20 |
CREATE SCHEMADatabases & Schemas define a new schema | 10 – 20 |
CREATE TABLESPACEDatabases & Schemas define a new tablespace | 10 – 20 |
DROP DATABASEDatabases & Schemas remove a database | 10 – 20 |
DROP SCHEMADatabases & Schemas remove a schema | 10 – 20 |
DROP TABLESPACEDatabases & Schemas remove a tablespace | 10 – 20 |
ALTER EXTENSIONExtensions & Access Methods change the definition of an extension | 10 – 20 |
CREATE ACCESS METHODExtensions & Access Methods define a new access method | 10 – 20 |
CREATE EXTENSIONExtensions & Access Methods install an extension | 10 – 20 |
DROP ACCESS METHODExtensions & Access Methods remove an access method | 10 – 20 |
DROP EXTENSIONExtensions & Access Methods remove an extension | 10 – 20 |
LOADExtensions & Access Methods load a shared library file | 10 – 20 |
ALTER FOREIGN DATA WRAPPERForeign Data change the definition of a foreign-data wrapper | 10 – 20 |
ALTER FOREIGN TABLEForeign Data change the definition of a foreign table | 10 – 20 |
ALTER SERVERForeign Data change the definition of a foreign server | 10 – 20 |
ALTER USER MAPPINGForeign Data change the definition of a user mapping | 10 – 20 |
CREATE FOREIGN DATA WRAPPERForeign Data define a new foreign-data wrapper | 10 – 20 |
CREATE FOREIGN TABLEForeign Data define a new foreign table | 10 – 20 |
CREATE SERVERForeign Data define a new foreign server | 10 – 20 |
CREATE USER MAPPINGForeign Data define a new mapping of a user to a foreign server | 10 – 20 |
DROP FOREIGN DATA WRAPPERForeign Data remove a foreign-data wrapper | 10 – 20 |
DROP FOREIGN TABLEForeign Data remove a foreign table | 10 – 20 |
DROP SERVERForeign Data remove a foreign server descriptor | 10 – 20 |
DROP USER MAPPINGForeign Data remove a user mapping for a foreign server | 10 – 20 |
IMPORT FOREIGN SCHEMAForeign Data import table definitions from a foreign server | 10 – 20 |
ALTER AGGREGATEFunctions & Procedures change the definition of an aggregate function | 10 – 20 |
ALTER FUNCTIONFunctions & Procedures change the definition of a function | 10 – 20 |
ALTER LANGUAGEFunctions & Procedures change the definition of a procedural language | 10 – 20 |
ALTER PROCEDUREFunctions & Procedures change the definition of a procedure | 11 – 20 |
ALTER ROUTINEFunctions & Procedures change the definition of a routine | 11 – 20 |
CALLFunctions & Procedures invoke a procedure | 11 – 20 |
CREATE AGGREGATEFunctions & Procedures define a new aggregate function | 10 – 20 |
CREATE FUNCTIONFunctions & Procedures define a new function | 10 – 20 |
CREATE LANGUAGEFunctions & Procedures define a new procedural language | 10 – 20 |
CREATE PROCEDUREFunctions & Procedures define a new procedure | 11 – 20 |
CREATE TRANSFORMFunctions & Procedures define a new transform | 10 – 20 |
DOFunctions & Procedures execute an anonymous code block | 10 – 20 |
DROP AGGREGATEFunctions & Procedures remove an aggregate function | 10 – 20 |
DROP FUNCTIONFunctions & Procedures remove a function | 10 – 20 |
DROP LANGUAGEFunctions & Procedures remove a procedural language | 10 – 20 |
DROP PROCEDUREFunctions & Procedures remove a procedure | 11 – 20 |
DROP ROUTINEFunctions & Procedures remove a routine | 11 – 20 |
DROP TRANSFORMFunctions & Procedures remove a transform | 10 – 20 |
ALTER INDEXIndexes & Statistics change the definition of an index | 10 – 20 |
ALTER STATISTICSIndexes & Statistics change the definition of an extended statistics object | 10 – 20 |
CREATE INDEXIndexes & Statistics define a new index | 10 – 20 |
CREATE STATISTICSIndexes & Statistics define extended statistics | 10 – 20 |
DROP INDEXIndexes & Statistics remove an index | 10 – 20 |
DROP STATISTICSIndexes & Statistics remove extended statistics | 10 – 20 |
REINDEXIndexes & Statistics rebuild indexes | 10 – 20 |
ALTER PUBLICATIONLogical Replication change the definition of a publication | 10 – 20 |
ALTER SUBSCRIPTIONLogical Replication change the definition of a subscription | 10 – 20 |
CREATE PUBLICATIONLogical Replication define a new publication | 10 – 20 |
CREATE SUBSCRIPTIONLogical Replication define a new subscription | 10 – 20 |
DROP PUBLICATIONLogical Replication remove a publication | 10 – 20 |
DROP SUBSCRIPTIONLogical Replication remove a subscription | 10 – 20 |
ANALYZEMaintenance collect statistics about a database | 10 – 20 |
CHECKPOINTMaintenance force a write-ahead log checkpoint | 10 – 20 |
CLUSTERMaintenance cluster a table according to an index | 10 – 20 |
VACUUMMaintenance garbage-collect and optionally analyze a database | 10 – 20 |
ALTER LARGE OBJECTOther Objects change the definition of a large object | 10 – 20 |
ALTER PROPERTY GRAPHOther Objects change the definition of an SQL-property graph | 19 – 19 · No PG 18 snapshot |
COMMENTOther Objects define or change the comment of an object | 10 – 20 |
CREATE PROPERTY GRAPHOther Objects define a new SQL-property graph | 19 – 19 · No PG 18 snapshot |
DROP PROPERTY GRAPHOther Objects remove an SQL-property graph | 19 – 19 · No PG 18 snapshot |
REPACKOther Objects rewrite a table to reclaim disk space | 19 – 20 · No PG 18 snapshot |
COPYQueries & Data copy data between a file and a table | 10 – 20 |
DELETEQueries & Data delete rows of a table | 10 – 20 |
EXPLAINQueries & Data show the execution plan of a statement | 10 – 20 |
INSERTQueries & Data create new rows in a table | 10 – 20 |
LOCKQueries & Data lock a table | 10 – 20 |
MERGEQueries & Data conditionally insert, update, or delete rows of a table | 15 – 20 |
SELECTQueries & Data retrieve rows from a table or view | 10 – 20 |
SELECT INTOQueries & Data define a new table from the results of a query | 10 – 20 |
UPDATEQueries & Data update rows of a table | 10 – 20 |
VALUESQueries & Data compute a set of rows | 10 – 20 |
ALTER DEFAULT PRIVILEGESRoles & Privileges define default access privileges | 10 – 20 |
ALTER GROUPRoles & Privileges change role name or membership | 10 – 20 |
ALTER POLICYRoles & Privileges change the definition of a row-level security policy | 10 – 20 |
ALTER ROLERoles & Privileges change a database role | 10 – 20 |
ALTER USERRoles & Privileges change a database role | 10 – 20 |
CREATE GROUPRoles & Privileges define a new database role | 10 – 20 |
CREATE POLICYRoles & Privileges define a new row-level security policy for a table | 10 – 20 |
CREATE ROLERoles & Privileges define a new database role | 10 – 20 |
CREATE USERRoles & Privileges define a new database role | 10 – 20 |
DROP GROUPRoles & Privileges remove a database role | 10 – 20 |
DROP OWNEDRoles & Privileges remove database objects owned by a database role | 10 – 20 |
DROP POLICYRoles & Privileges remove a row-level security policy from a table | 10 – 20 |
DROP ROLERoles & Privileges remove a database role | 10 – 20 |
DROP USERRoles & Privileges remove a database role | 10 – 20 |
GRANTRoles & Privileges define access privileges | 10 – 20 |
REASSIGN OWNEDRoles & Privileges change the ownership of database objects owned by a database role | 10 – 20 |
REVOKERoles & Privileges remove access privileges | 10 – 20 |
SECURITY LABELRoles & Privileges define or change a security label applied to an object | 10 – 20 |
SET ROLERoles & Privileges set the current user identifier of the current session | 10 – 20 |
SET SESSION AUTHORIZATIONRoles & Privileges set the session user identifier and the current user identifier of the current session | 10 – 20 |
ALTER SYSTEMSessions & Settings change a server configuration parameter | 10 – 20 |
DISCARDSessions & Settings discard session state | 10 – 20 |
LISTENSessions & Settings listen for a notification | 10 – 20 |
NOTIFYSessions & Settings generate a notification | 10 – 20 |
RESETSessions & Settings restore the value of a run-time parameter to the default value | 10 – 20 |
SETSessions & Settings change a run-time parameter | 10 – 20 |
SHOWSessions & Settings show the value of a run-time parameter | 10 – 20 |
UNLISTENSessions & Settings stop listening for a notification | 10 – 20 |
ALTER MATERIALIZED VIEWTables & Views change the definition of a materialized view | 10 – 20 |
ALTER SEQUENCETables & Views change the definition of a sequence generator | 10 – 20 |
ALTER TABLETables & Views change the definition of a table | 10 – 20 |
ALTER VIEWTables & Views change the definition of a view | 10 – 20 |
CREATE MATERIALIZED VIEWTables & Views define a new materialized view | 10 – 20 |
CREATE SEQUENCETables & Views define a new sequence generator | 10 – 20 |
CREATE TABLETables & Views define a new table | 10 – 20 |
CREATE TABLE ASTables & Views define a new table from the results of a query | 10 – 20 |
CREATE VIEWTables & Views define a new view | 10 – 20 |
DROP MATERIALIZED VIEWTables & Views remove a materialized view | 10 – 20 |
DROP SEQUENCETables & Views remove a sequence | 10 – 20 |
DROP TABLETables & Views remove a table | 10 – 20 |
DROP VIEWTables & Views remove a view | 10 – 20 |
REFRESH MATERIALIZED VIEWTables & Views replace the contents of a materialized view | 10 – 20 |
TRUNCATETables & Views empty a table or set of tables | 10 – 20 |
ALTER TEXT SEARCH CONFIGURATIONText Search change the definition of a text search configuration | 10 – 20 |
ALTER TEXT SEARCH DICTIONARYText Search change the definition of a text search dictionary | 10 – 20 |
ALTER TEXT SEARCH PARSERText Search change the definition of a text search parser | 10 – 20 |
ALTER TEXT SEARCH TEMPLATEText Search change the definition of a text search template | 10 – 20 |
CREATE TEXT SEARCH CONFIGURATIONText Search define a new text search configuration | 10 – 20 |
CREATE TEXT SEARCH DICTIONARYText Search define a new text search dictionary | 10 – 20 |
CREATE TEXT SEARCH PARSERText Search define a new text search parser | 10 – 20 |
CREATE TEXT SEARCH TEMPLATEText Search define a new text search template | 10 – 20 |
DROP TEXT SEARCH CONFIGURATIONText Search remove a text search configuration | 10 – 20 |
DROP TEXT SEARCH DICTIONARYText Search remove a text search dictionary | 10 – 20 |
DROP TEXT SEARCH PARSERText Search remove a text search parser | 10 – 20 |
DROP TEXT SEARCH TEMPLATEText Search remove a text search template | 10 – 20 |
ABORTTransactions abort the current transaction | 10 – 20 |
BEGINTransactions start a transaction block | 10 – 20 |
COMMITTransactions commit the current transaction | 10 – 20 |
COMMIT PREPAREDTransactions commit a transaction that was earlier prepared for two-phase commit | 10 – 20 |
ENDTransactions commit the current transaction | 10 – 20 |
PREPARE TRANSACTIONTransactions prepare the current transaction for two-phase commit | 10 – 20 |
RELEASE SAVEPOINTTransactions release a previously defined savepoint | 10 – 20 |
ROLLBACKTransactions abort the current transaction | 10 – 20 |
ROLLBACK PREPAREDTransactions cancel a transaction that was earlier prepared for two-phase commit | 10 – 20 |
ROLLBACK TO SAVEPOINTTransactions roll back to a savepoint | 10 – 20 |
SAVEPOINTTransactions define a new savepoint within the current transaction | 10 – 20 |
SET CONSTRAINTSTransactions set constraint check timing for the current transaction | 10 – 20 |
SET TRANSACTIONTransactions set the characteristics of the current transaction | 10 – 20 |
START TRANSACTIONTransactions start a transaction block | 10 – 20 |
WAIT FORTransactions wait for WAL to reach a target LSN | 19 – 20 · No PG 18 snapshot |
ALTER EVENT TRIGGERTriggers & Rules change the definition of an event trigger | 10 – 20 |
ALTER RULETriggers & Rules change the definition of a rule | 10 – 20 |
ALTER TRIGGERTriggers & Rules change the definition of a trigger | 10 – 20 |
CREATE EVENT TRIGGERTriggers & Rules define a new event trigger | 10 – 20 |
CREATE RULETriggers & Rules define a new rewrite rule | 10 – 20 |
CREATE TRIGGERTriggers & Rules define a new trigger | 10 – 20 |
DROP EVENT TRIGGERTriggers & Rules remove an event trigger | 10 – 20 |
DROP RULETriggers & Rules remove a rewrite rule | 10 – 20 |
DROP TRIGGERTriggers & Rules remove a trigger | 10 – 20 |
ALTER COLLATIONTypes & Operators change the definition of a collation | 10 – 20 |
ALTER CONVERSIONTypes & Operators change the definition of a conversion | 10 – 20 |
ALTER DOMAINTypes & Operators change the definition of a domain | 10 – 20 |
ALTER OPERATORTypes & Operators change the definition of an operator | 10 – 20 |
ALTER OPERATOR CLASSTypes & Operators change the definition of an operator class | 10 – 20 |
ALTER OPERATOR FAMILYTypes & Operators change the definition of an operator family | 10 – 20 |
ALTER TYPETypes & Operators change the definition of a type | 10 – 20 |
CREATE CASTTypes & Operators define a new cast | 10 – 20 |
CREATE COLLATIONTypes & Operators define a new collation | 10 – 20 |
CREATE CONVERSIONTypes & Operators define a new encoding conversion | 10 – 20 |
CREATE DOMAINTypes & Operators define a new domain | 10 – 20 |
CREATE OPERATORTypes & Operators define a new operator | 10 – 20 |
CREATE OPERATOR CLASSTypes & Operators define a new operator class | 10 – 20 |
CREATE OPERATOR FAMILYTypes & Operators define a new operator family | 10 – 20 |
CREATE TYPETypes & Operators define a new data type | 10 – 20 |
DROP CASTTypes & Operators remove a cast | 10 – 20 |
DROP COLLATIONTypes & Operators remove a collation | 10 – 20 |
DROP CONVERSIONTypes & Operators remove a conversion | 10 – 20 |
DROP DOMAINTypes & Operators remove a domain | 10 – 20 |
DROP OPERATORTypes & Operators remove an operator | 10 – 20 |
DROP OPERATOR CLASSTypes & Operators remove an operator class | 10 – 20 |
DROP OPERATOR FAMILYTypes & Operators remove an operator family | 10 – 20 |
DROP TYPETypes & Operators remove a data type | 10 – 20 |