Chapter 14. PostgreSQL Command Reference

Table of Contents
ABORT -- Rolls back changes made during a transaction block.
ALTER GROUP -- Modifies the structure of a user group.
ALTER TABLE -- Modifies table and column attributes.
ALTER USER -- Modifies user properties and permissions.
BEGIN -- Starts a chained-mode transaction block.
CLOSE -- Closes a previously defined cursor object.
CLUSTER -- Provides the backend server with clustering information about a table.
COMMENT -- Adds a comment to an object within the database.
COMMIT -- Ends the current transaction block and finalizes changes made within it.
COPY -- Copies data between files and tables.
CREATE AGGREGATE -- Defines a new aggregate function within the database.
CREATE DATABASE -- Creates a new database in PostgreSQL.
CREATE FUNCTION -- Defines a new function within the database.
CREATE GROUP -- Creates a new PostgreSQL group within the database.
CREATE INDEX -- Places an index on a table.
CREATE LANGUAGE -- Defines a new language to be used by functions.
CREATE OPERATOR -- Defines a new operator within the database.
CREATE RULE -- Defines a new rule on a table.
CREATE SEQUENCE -- Creates a new sequence number generator.
CREATE TABLE -- Creates a new table.
CREATE TABLE AS -- Creates a new table built from data retrieved by a SELECT.
CREATE TRIGGER -- Creates a new trigger.
CREATE TYPE -- Defines a new data type for use in the database.
CREATE USER -- Creates a new PostgreSQL database user.
CREATE VIEW -- Creates a view on a table.
CURRENT_DATE -- Returns the current date.
CURRENT_TIME -- Returns the current time.
CURRENT_TIMESTAMP -- Returns the current date and time.
CURRENT_USER -- Returns the current database username.
DECLARE -- Defines a new cursor.
DELETE -- Removes rows from a table.
DROP AGGREGATE -- Removes an aggregate function from a database.
DROP DATABASE -- Removes a database from the system.
DROP FUNCTION -- Removes a user-defined function.
DROP GROUP -- Removes a user group from the database.
DROP INDEX -- Removes an index from a database.
DROP LANGUAGE -- Removes a procedural language from a database.
DROP OPERATOR -- Removes an operator from the database.
DROP RULE -- Removes a rule from a database.
DROP SEQUENCE -- Removes a sequence from a database.
DROP TABLE -- Removes a table from a database.
DROP TRIGGER -- Removes a trigger definition from a database.
DROP TYPE -- Removes a type from the system catalogs.
DROP USER -- Removes a PostgreSQL user.
DROP VIEW -- Removes an existing view from a database.
END -- Ends the current transaction block and finalizes its modifications.
EXPLAIN -- Shows the statement execution plan for a supplied query.
FETCH -- Retrieves rows from a cursor.
GRANT -- Grants access privileges to a user, a group, or to all users in the database.
INSERT -- Inserts new rows into a table.
LISTEN -- Listen for a notification event.
LOAD -- Dynamically loads object files into a database.
LOCK -- Locks a table within a transaction.
MOVE -- Repositions a cursor to another row.
NOTIFY -- Signals all backends that are listening for the specified notify event.
REINDEX -- Rebuilds indices on tables.
RESET -- Restores runtime variables to their default settings.
REVOKE -- Revokes access privileges from a user, a group, or all users.
ROLLBACK -- Aborts the current transaction block and abandons any modifications it would have made.
SELECT -- Retrieves rows from a table or view.
SELECT INTO -- Construct a new table from the results of a SELECT.
SET -- Set runtime variables.
SET CONSTRAINTS -- Sets the constraint mode for the current transaction block.
SET TRANSACTION -- Sets the transaction isolation level for the current transaction block.
SHOW -- Displays the values of runtime variables.
TRUNCATE -- Empties the contents of a table.
UNLISTEN -- Stops the backend process from listening for a notification event.
UPDATE -- Modifies the values of column data within a table.
VACUUM -- Cleans and analyzes a database.

This command reference covers each of the major SQL commands supported by PostgreSQL. It contains both standard SQL commands (e.g., INSERT, SELECT) and PostgreSQL-specific commands (e.g., CREATE OPERATOR, CREATE TYPE).

Each reference entry is broken up into three sections: a synopsis, a description, and an examples section. The synopsis contains a syntax diagram, parameter explanation, and a list of possible results from executing the command. The description briefly summarizes the general use of the command. The examples section contains at least one functional example of using the command.