PostgreSQL 18 Official Documentation🌐 εˆ‡ζ’εˆ°δΈ­ζ–‡η‰ˆ β†’

SQL Commands


This part contains reference information for the SQL commands supported by PostgreSQL. By β€œSQL” the language in general is meant; information about the standards conformance and compatibility of each command can be found on the respective reference page.

Table of Contents

ABORT β€” abort the current transaction
ALTER AGGREGATE β€” change the definition of an aggregate function
ALTER COLLATION β€” change the definition of a collation
ALTER CONVERSION β€” change the definition of a conversion
ALTER DATABASE β€” change a database
ALTER DEFAULT PRIVILEGES β€” define default access privileges
ALTER DOMAIN β€” change the definition of a domain
ALTER EVENT TRIGGER β€” change the definition of an event trigger
ALTER EXTENSION β€” change the definition of an extension
ALTER FOREIGN DATA WRAPPER β€” change the definition of a foreign-data wrapper
ALTER FOREIGN TABLE β€” change the definition of a foreign table
ALTER FUNCTION β€” change the definition of a function
ALTER GROUP β€” change role name or membership
ALTER INDEX β€” change the definition of an index
ALTER LANGUAGE β€” change the definition of a procedural language
ALTER LARGE OBJECT β€” change the definition of a large object
ALTER MATERIALIZED VIEW β€” change the definition of a materialized view
ALTER OPERATOR β€” change the definition of an operator
ALTER OPERATOR CLASS β€” change the definition of an operator class
ALTER OPERATOR FAMILY β€” change the definition of an operator family
ALTER POLICY β€” change the definition of a row-level security policy
ALTER PROCEDURE β€” change the definition of a procedure
ALTER PUBLICATION β€” change the definition of a publication
ALTER ROLE β€” change a database role
ALTER ROUTINE β€” change the definition of a routine
ALTER RULE β€” change the definition of a rule
ALTER SCHEMA β€” change the definition of a schema
ALTER SEQUENCE β€” change the definition of a sequence generator
ALTER SERVER β€” change the definition of a foreign server
ALTER STATISTICS β€” change the definition of an extended statistics object
ALTER SUBSCRIPTION β€” change the definition of a subscription
ALTER SYSTEM β€” change a server configuration parameter
ALTER TABLE β€” change the definition of a table
ALTER TABLESPACE β€” change the definition of a tablespace
ALTER TEXT SEARCH CONFIGURATION β€” change the definition of a text search configuration
ALTER TEXT SEARCH DICTIONARY β€” change the definition of a text search dictionary
ALTER TEXT SEARCH PARSER β€” change the definition of a text search parser
ALTER TEXT SEARCH TEMPLATE β€” change the definition of a text search template
ALTER TRIGGER β€” change the definition of a trigger
ALTER TYPE β€” change the definition of a type
ALTER USER β€” change a database role
ALTER USER MAPPING β€” change the definition of a user mapping
ALTER VIEW β€” change the definition of a view
ANALYZE β€” collect statistics about a database
BEGIN β€” start a transaction block
CALL β€” invoke a procedure
CHECKPOINT β€” force a write-ahead log checkpoint
CLOSE β€” close a cursor
CLUSTER β€” cluster a table according to an index
COMMENT β€” define or change the comment of an object
COMMIT β€” commit the current transaction
COMMIT PREPARED β€” commit a transaction that was earlier prepared for two-phase commit
COPY β€” copy data between a file and a table
CREATE ACCESS METHOD β€” define a new access method
CREATE AGGREGATE β€” define a new aggregate function
CREATE CAST β€” define a new cast
CREATE COLLATION β€” define a new collation
CREATE CONVERSION β€” define a new encoding conversion
CREATE DATABASE β€” create a new database
CREATE DOMAIN β€” define a new domain
CREATE EVENT TRIGGER β€” define a new event trigger
CREATE EXTENSION β€” install an extension
CREATE FOREIGN DATA WRAPPER β€” define a new foreign-data wrapper
CREATE FOREIGN TABLE β€” define a new foreign table
CREATE FUNCTION β€” define a new function
CREATE GROUP β€” define a new database role
CREATE INDEX β€” define a new index
CREATE LANGUAGE β€” define a new procedural language
CREATE MATERIALIZED VIEW β€” define a new materialized view
CREATE OPERATOR β€” define a new operator
CREATE OPERATOR CLASS β€” define a new operator class
CREATE OPERATOR FAMILY β€” define a new operator family
CREATE POLICY β€” define a new row-level security policy for a table
CREATE PROCEDURE β€” define a new procedure
CREATE PUBLICATION β€” define a new publication
CREATE ROLE β€” define a new database role
CREATE RULE β€” define a new rewrite rule
CREATE SCHEMA β€” define a new schema
CREATE SEQUENCE β€” define a new sequence generator
CREATE SERVER β€” define a new foreign server
CREATE STATISTICS β€” define extended statistics
CREATE SUBSCRIPTION β€” define a new subscription
CREATE TABLE β€” define a new table
CREATE TABLE AS β€” define a new table from the results of a query
CREATE TABLESPACE β€” define a new tablespace
CREATE TEXT SEARCH CONFIGURATION β€” define a new text search configuration
CREATE TEXT SEARCH DICTIONARY β€” define a new text search dictionary
CREATE TEXT SEARCH PARSER β€” define a new text search parser
CREATE TEXT SEARCH TEMPLATE β€” define a new text search template
CREATE TRANSFORM β€” define a new transform
CREATE TRIGGER β€” define a new trigger
CREATE TYPE β€” define a new data type
CREATE USER β€” define a new database role
CREATE USER MAPPING β€” define a new mapping of a user to a foreign server
CREATE VIEW β€” define a new view
DEALLOCATE β€” deallocate a prepared statement
DECLARE β€” define a cursor
DELETE β€” delete rows of a table
DISCARD β€” discard session state
DO β€” execute an anonymous code block
DROP ACCESS METHOD β€” remove an access method
DROP AGGREGATE β€” remove an aggregate function
DROP CAST β€” remove a cast
DROP COLLATION β€” remove a collation
DROP CONVERSION β€” remove a conversion
DROP DATABASE β€” remove a database
DROP DOMAIN β€” remove a domain
DROP EVENT TRIGGER β€” remove an event trigger
DROP EXTENSION β€” remove an extension
DROP FOREIGN DATA WRAPPER β€” remove a foreign-data wrapper
DROP FOREIGN TABLE β€” remove a foreign table
DROP FUNCTION β€” remove a function
DROP GROUP β€” remove a database role
DROP INDEX β€” remove an index
DROP LANGUAGE β€” remove a procedural language
DROP MATERIALIZED VIEW β€” remove a materialized view
DROP OPERATOR β€” remove an operator
DROP OPERATOR CLASS β€” remove an operator class
DROP OPERATOR FAMILY β€” remove an operator family
DROP OWNED β€” remove database objects owned by a database role
DROP POLICY β€” remove a row-level security policy from a table
DROP PROCEDURE β€” remove a procedure
DROP PUBLICATION β€” remove a publication
DROP ROLE β€” remove a database role
DROP ROUTINE β€” remove a routine
DROP RULE β€” remove a rewrite rule
DROP SCHEMA β€” remove a schema
DROP SEQUENCE β€” remove a sequence
DROP SERVER β€” remove a foreign server descriptor
DROP STATISTICS β€” remove extended statistics
DROP SUBSCRIPTION β€” remove a subscription
DROP TABLE β€” remove a table
DROP TABLESPACE β€” remove a tablespace
DROP TEXT SEARCH CONFIGURATION β€” remove a text search configuration
DROP TEXT SEARCH DICTIONARY β€” remove a text search dictionary
DROP TEXT SEARCH PARSER β€” remove a text search parser
DROP TEXT SEARCH TEMPLATE β€” remove a text search template
DROP TRANSFORM β€” remove a transform
DROP TRIGGER β€” remove a trigger
DROP TYPE β€” remove a data type
DROP USER β€” remove a database role
DROP USER MAPPING β€” remove a user mapping for a foreign server
DROP VIEW β€” remove a view
END β€” commit the current transaction
EXECUTE β€” execute a prepared statement
EXPLAIN β€” show the execution plan of a statement
FETCH β€” retrieve rows from a query using a cursor
GRANT β€” define access privileges
IMPORT FOREIGN SCHEMA β€” import table definitions from a foreign server
INSERT β€” create new rows in a table
LISTEN β€” listen for a notification
LOAD β€” load a shared library file
LOCK β€” lock a table
MERGE β€” conditionally insert, update, or delete rows of a table
MOVE β€” position a cursor
NOTIFY β€” generate a notification
PREPARE β€” prepare a statement for execution
PREPARE TRANSACTION β€” prepare the current transaction for two-phase commit
REASSIGN OWNED β€” change the ownership of database objects owned by a database role
REFRESH MATERIALIZED VIEW β€” replace the contents of a materialized view
REINDEX β€” rebuild indexes
RELEASE SAVEPOINT β€” release a previously defined savepoint
RESET β€” restore the value of a run-time parameter to the default value
REVOKE β€” remove access privileges
ROLLBACK β€” abort the current transaction
ROLLBACK PREPARED β€” cancel a transaction that was earlier prepared for two-phase commit
ROLLBACK TO SAVEPOINT β€” roll back to a savepoint
SAVEPOINT β€” define a new savepoint within the current transaction
SECURITY LABEL β€” define or change a security label applied to an object
SELECT β€” retrieve rows from a table or view
SELECT INTO β€” define a new table from the results of a query
SET β€” change a run-time parameter
SET CONSTRAINTS β€” set constraint check timing for the current transaction
SET ROLE β€” set the current user identifier of the current session
SET SESSION AUTHORIZATION β€” set the session user identifier and the current user identifier of the current session
SET TRANSACTION β€” set the characteristics of the current transaction
SHOW β€” show the value of a run-time parameter
START TRANSACTION β€” start a transaction block
TRUNCATE β€” empty a table or set of tables
UNLISTEN β€” stop listening for a notification
UPDATE β€” update rows of a table
VACUUM β€” garbage-collect and optionally analyze a database
VALUES β€” compute a set of rows