Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2 / 7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

Appendix B. SQL Key Words

Table B-1 lists all tokens that are key words in the SQL standard and in PostgreSQL 7.1.3. Background information can be found in Section 1.1.1.

SQL distinguishes between reserved and non-reserved key words. Reserved key words are the only real key words; they are never allowed as identifiers. Non-reserved key words only have a special meaning in particular contexts and can be used as identifiers in other contexts. Most non-reserved key words are actually the names of built-in tables and functions specified by SQL and the concept of non-reserved key words essentially only exists to declare that some predefined meaning is attached to a word in some contexts.

In the PostgreSQL parser life is a bit more complicated. There are several different classes of tokens ranging from those that can never be used as an identifier to those that have absolutely no special status in the parser as compared to an ordinary identifier. (The latter is usually the case for functions specified by SQL.) Most SQL reserved key words are not completely reserved in PostgreSQL, but can be used as column label (as in SELECT 55 AS CHECK, even though CHECK is a reserved key word).

In Table B-1 in the column for PostgreSQL we classify as "non-reserved" those key words that are explicitly known to the parser but are allowed in most or all contexts where an identifier is expected. Labeled "reserved" are those tokens that are only allowed as "AS" column label names (and perhaps in very few other contexts). The token AS is the only exception: it cannot even be used as a column label. As a general rule, if you get spurious parser errors for commands that contain any of the listed key words as an identifier you should try to quote the identifier to see if the problem goes away.

It is important to understand before studying Table B-1 that the fact that a key word is not reserved in PostgreSQL does not mean that the feature related to the word is not implemented. Conversely, the presence of a key word does not indicate the existence of a feature.

Table B-1. SQL Key Words

Key Word PostgreSQL SQL 99 SQL 92
ABORT reserved    
ABS   non-reserved  
ABSOLUTE non-reserved reserved reserved
ACCESS non-reserved    
ACTION non-reserved reserved reserved
ADA   non-reserved non-reserved
ADD non-reserved reserved reserved
ADMIN   reserved  
AFTER non-reserved reserved  
AGGREGATE non-reserved reserved  
ALIAS   reserved  
ALL reserved reserved reserved
ALLOCATE   reserved reserved
ALTER non-reserved reserved reserved
ANALYSE reserved    
ANALYZE reserved    
AND reserved reserved reserved
ANY reserved reserved reserved
ARE   reserved reserved
ARRAY   reserved  
AS reserved reserved reserved
ASC reserved reserved reserved
ASENSITIVE   non-reserved  
ASSERTION   reserved reserved
ASSIGNMENT   non-reserved  
ASYMMETRIC   non-reserved  
AT non-reserved reserved reserved
ATOMIC   non-reserved  
AUTHORIZATION   reserved reserved
AVG   non-reserved reserved
BACKWARD non-reserved    
BEFORE non-reserved reserved  
BEGIN non-reserved reserved reserved
BETWEEN reserved non-reserved reserved
BINARY reserved reserved  
BIT reserved reserved reserved
BITVAR   non-reserved  
BIT_LENGTH   non-reserved reserved
BLOB   reserved  
BOOLEAN   reserved  
BOTH reserved reserved reserved
BREADTH   reserved  
BY non-reserved reserved reserved
C   non-reserved non-reserved
CACHE non-reserved    
CALL   reserved  
CALLED   non-reserved  
CARDINALITY   non-reserved  
CASCADE non-reserved reserved reserved
CASCADED   reserved reserved
CASE reserved reserved reserved
CAST reserved reserved reserved
CATALOG   reserved reserved
CATALOG_NAME   non-reserved non-reserved
CHAIN non-reserved non-reserved  
CHAR reserved reserved reserved
CHARACTER reserved reserved reserved
CHARACTERISTICS non-reserved    
CHARACTER_LENGTH   non-reserved reserved
CHARACTER_SET_CATALOG   non-reserved non-reserved
CHARACTER_SET_NAME   non-reserved non-reserved
CHARACTER_SET_SCHEMA   non-reserved non-reserved
CHAR_LENGTH   non-reserved reserved
CHECK reserved reserved reserved
CHECKED   non-reserved  
CHECKPOINT non-reserved    
CLASS   reserved  
CLASS_ORIGIN   non-reserved non-reserved
CLOB   reserved  
CLOSE non-reserved reserved reserved
CLUSTER reserved    
COALESCE reserved non-reserved reserved
COBOL   non-reserved non-reserved
COLLATE reserved reserved reserved
COLLATION   reserved reserved
COLLATION_CATALOG   non-reserved non-reserved
COLLATION_NAME   non-reserved non-reserved
COLLATION_SCHEMA   non-reserved non-reserved
COLUMN reserved reserved reserved
COLUMN_NAME   non-reserved non-reserved
COMMAND_FUNCTION   non-reserved non-reserved
COMMAND_FUNCTION_CODE   non-reserved  
COMMENT non-reserved    
COMMIT non-reserved reserved reserved
COMMITTED non-reserved non-reserved non-reserved
COMPLETION   reserved  
CONDITION_NUMBER   non-reserved non-reserved
CONNECT   reserved reserved
CONNECTION   reserved reserved
CONNECTION_NAME   non-reserved non-reserved
CONSTRAINT reserved reserved reserved
CONSTRAINTS non-reserved reserved reserved
CONSTRAINT_CATALOG   non-reserved non-reserved
CONSTRAINT_NAME   non-reserved non-reserved
CONSTRAINT_SCHEMA   non-reserved non-reserved
CONSTRUCTOR   reserved  
CONTAINS   non-reserved  
CONTINUE   reserved reserved
CONVERT   non-reserved reserved
COPY reserved    
CORRESPONDING   reserved reserved
COUNT   non-reserved reserved
CREATE non-reserved reserved reserved
CREATEDB non-reserved    
CREATEUSER non-reserved    
CROSS reserved reserved reserved
CUBE   reserved  
CURRENT   reserved reserved
CURRENT_DATE reserved reserved reserved
CURRENT_PATH   reserved  
CURRENT_ROLE   reserved  
CURRENT_TIME reserved reserved reserved
CURRENT_TIMESTAMP reserved reserved reserved
CURRENT_USER reserved reserved reserved
CURSOR non-reserved reserved reserved
CURSOR_NAME   non-reserved non-reserved
CYCLE non-reserved reserved  
DATA   reserved non-reserved
DATABASE non-reserved    
DATE   reserved reserved
DATETIME_INTERVAL_CODE   non-reserved non-reserved
DATETIME_INTERVAL_PRECISION   non-reserved non-reserved
DAY non-reserved reserved reserved
DEALLOCATE   reserved reserved
DEC reserved reserved reserved
DECIMAL reserved reserved reserved
DECLARE non-reserved reserved reserved
DEFAULT reserved reserved reserved
DEFERRABLE reserved reserved reserved
DEFERRED non-reserved reserved reserved
DEFINED   non-reserved  
DEFINER   non-reserved  
DELETE non-reserved reserved reserved
DELIMITERS non-reserved    
DEPTH   reserved  
DEREF   reserved  
DESC reserved reserved reserved
DESCRIBE   reserved reserved
DESCRIPTOR   reserved reserved
DESTROY   reserved  
DESTRUCTOR   reserved  
DETERMINISTIC   reserved  
DIAGNOSTICS   reserved reserved
DICTIONARY   reserved  
DISCONNECT   reserved reserved
DISPATCH   non-reserved  
DISTINCT reserved reserved reserved
DO reserved    
DOMAIN   reserved reserved
DOUBLE non-reserved reserved reserved
DROP non-reserved reserved reserved
DYNAMIC   reserved  
DYNAMIC_FUNCTION   non-reserved non-reserved
DYNAMIC_FUNCTION_CODE   non-reserved  
EACH non-reserved reserved  
ELSE reserved reserved reserved
ENCODING non-reserved    
END reserved reserved reserved
END-EXEC   reserved reserved
EQUALS   reserved  
ESCAPE non-reserved reserved reserved
EVERY   reserved  
EXCEPT reserved reserved reserved
EXCEPTION   reserved reserved
EXCLUSIVE non-reserved    
EXEC   reserved reserved
EXECUTE non-reserved reserved reserved
EXISTING   non-reserved  
EXISTS reserved non-reserved reserved
EXPLAIN reserved    
EXTEND reserved    
EXTERNAL   reserved reserved
EXTRACT reserved non-reserved reserved
FALSE reserved reserved reserved
FETCH non-reserved reserved reserved
FINAL   non-reserved  
FIRST   reserved reserved
FLOAT reserved reserved reserved
FOR reserved reserved reserved
FORCE non-reserved    
FOREIGN reserved reserved reserved
FORTRAN   non-reserved non-reserved
FORWARD non-reserved    
FOUND   reserved reserved
FREE   reserved  
FROM reserved reserved reserved
FULL reserved reserved reserved
FUNCTION non-reserved reserved  
G   non-reserved  
GENERAL   reserved  
GENERATED   non-reserved  
GET   reserved reserved
GLOBAL reserved reserved reserved
GO   reserved reserved
GOTO   reserved reserved
GRANT non-reserved reserved reserved
GRANTED   non-reserved  
GROUP reserved reserved reserved
GROUPING   reserved  
HANDLER non-reserved    
HAVING reserved reserved reserved
HIERARCHY   non-reserved  
HOLD   non-reserved  
HOST   reserved  
HOUR non-reserved reserved reserved
IDENTITY   reserved reserved
IGNORE   reserved  
ILIKE reserved    
IMMEDIATE non-reserved reserved reserved
IMPLEMENTATION   non-reserved  
IN reserved reserved reserved
INCREMENT non-reserved    
INDEX non-reserved    
INDICATOR   reserved reserved
INFIX   non-reserved  
INHERITS non-reserved    
INITIALIZE   reserved  
INITIALLY reserved reserved reserved
INNER reserved reserved reserved
INOUT reserved reserved  
INPUT   reserved reserved
INSENSITIVE non-reserved non-reserved reserved
INSERT non-reserved reserved reserved
INSTANCE   non-reserved  
INSTANTIABLE   non-reserved  
INSTEAD non-reserved    
INT   reserved reserved
INTEGER   reserved reserved
INTERSECT reserved reserved reserved
INTERVAL non-reserved reserved reserved
INTO reserved reserved reserved
INVOKER   non-reserved  
IS reserved reserved reserved
ISNULL reserved    
ISOLATION non-reserved reserved reserved
ITERATE   reserved  
JOIN reserved reserved reserved
K   non-reserved  
KEY non-reserved reserved reserved
KEY_MEMBER   non-reserved  
KEY_TYPE   non-reserved  
LANCOMPILER non-reserved    
LANGUAGE non-reserved reserved reserved
LARGE   reserved  
LAST   reserved reserved
LATERAL   reserved  
LEADING reserved reserved reserved
LEFT reserved reserved reserved
LENGTH   non-reserved non-reserved
LESS   reserved  
LEVEL non-reserved reserved reserved
LIKE reserved reserved reserved
LIMIT reserved reserved  
LISTEN reserved    
LOAD reserved    
LOCAL reserved reserved reserved
LOCALTIME   reserved  
LOCALTIMESTAMP   reserved  
LOCATION non-reserved    
LOCATOR   reserved  
LOCK reserved    
LOWER   non-reserved reserved
M   non-reserved  
MAP   reserved  
MATCH non-reserved reserved reserved
MAX   non-reserved reserved
MAXVALUE non-reserved    
MESSAGE_LENGTH   non-reserved non-reserved
MESSAGE_OCTET_LENGTH   non-reserved non-reserved
MESSAGE_TEXT   non-reserved non-reserved
METHOD   non-reserved  
MIN   non-reserved reserved
MINUTE non-reserved reserved reserved
MINVALUE non-reserved    
MOD   non-reserved  
MODE non-reserved    
MODIFIES   reserved  
MODIFY   reserved  
MODULE   reserved reserved
MONTH non-reserved reserved reserved
MORE   non-reserved non-reserved
MOVE reserved    
MUMPS   non-reserved non-reserved
NAME   non-reserved non-reserved
NAMES non-reserved reserved reserved
NATIONAL non-reserved reserved reserved
NATURAL reserved reserved reserved
NCHAR reserved reserved reserved
NCLOB   reserved  
NEW reserved reserved  
NEXT non-reserved reserved reserved
NO non-reserved reserved reserved
NOCREATEDB non-reserved    
NOCREATEUSER non-reserved    
NONE non-reserved reserved  
NOT reserved reserved reserved
NOTHING non-reserved    
NOTIFY non-reserved    
NOTNULL reserved    
NULL reserved reserved reserved
NULLABLE   non-reserved non-reserved
NULLIF reserved non-reserved reserved
NUMBER   non-reserved non-reserved
NUMERIC reserved reserved reserved
OBJECT   reserved  
OCTET_LENGTH   non-reserved reserved
OF non-reserved reserved reserved
OFF reserved reserved  
OFFSET reserved    
OIDS non-reserved    
OLD reserved reserved  
ON reserved reserved reserved
ONLY reserved reserved reserved
OPEN   reserved reserved
OPERATION   reserved  
OPERATOR non-reserved    
OPTION non-reserved reserved reserved
OPTIONS   non-reserved  
OR reserved reserved reserved
ORDER reserved reserved reserved
ORDINALITY   reserved  
OUT reserved reserved  
OUTER reserved reserved reserved
OUTPUT   reserved reserved
OVERLAPS reserved non-reserved reserved
OVERLAY   non-reserved  
OVERRIDING   non-reserved  
OWNER non-reserved    
PAD   reserved reserved
PARAMETER   reserved  
PARAMETERS   reserved  
PARAMETER_MODE   non-reserved  
PARAMETER_NAME   non-reserved  
PARAMETER_ORDINAL_POSITION   non-reserved  
PARAMETER_SPECIFIC_CATALOG   non-reserved  
PARAMETER_SPECIFIC_NAME   non-reserved  
PARAMETER_SPECIFIC_SCHEMA   non-reserved  
PARTIAL non-reserved reserved reserved
PASCAL   non-reserved non-reserved
PASSWORD non-reserved    
PATH non-reserved reserved  
PENDANT non-reserved    
PLI   non-reserved non-reserved
POSITION reserved non-reserved reserved
POSTFIX   reserved  
PRECISION reserved reserved reserved
PREFIX   reserved  
PREORDER   reserved  
PREPARE   reserved reserved
PRESERVE   reserved reserved
PRIMARY reserved reserved reserved
PRIOR non-reserved reserved reserved
PRIVILEGES non-reserved reserved reserved
PROCEDURAL non-reserved    
PROCEDURE non-reserved reserved reserved
PUBLIC reserved reserved reserved
READ non-reserved reserved reserved
READS   reserved  
REAL   reserved reserved
RECURSIVE   reserved  
REF   reserved  
REFERENCES reserved reserved reserved
REFERENCING   reserved  
REINDEX non-reserved    
RELATIVE non-reserved reserved reserved
RENAME non-reserved    
REPEATABLE   non-reserved non-reserved
RESET reserved    
RESTRICT non-reserved reserved reserved
RESULT   reserved  
RETURN   reserved  
RETURNED_LENGTH   non-reserved non-reserved
RETURNED_OCTET_LENGTH   non-reserved non-reserved
RETURNED_SQLSTATE   non-reserved non-reserved
RETURNS non-reserved reserved  
REVOKE non-reserved reserved reserved
RIGHT reserved reserved reserved
ROLE   reserved  
ROLLBACK non-reserved reserved reserved
ROLLUP   reserved  
ROUTINE   reserved  
ROUTINE_CATALOG   non-reserved  
ROUTINE_NAME   non-reserved  
ROUTINE_SCHEMA   non-reserved  
ROW non-reserved reserved  
ROWS   reserved reserved
ROW_COUNT   non-reserved non-reserved
RULE non-reserved    
SAVEPOINT   reserved  
SCALE   non-reserved non-reserved
SCHEMA non-reserved reserved reserved
SCHEMA_NAME   non-reserved non-reserved
SCOPE   reserved  
SCROLL non-reserved reserved reserved
SEARCH   reserved  
SECOND non-reserved reserved reserved
SECTION   reserved reserved
SECURITY   non-reserved  
SELECT reserved reserved reserved
SELF   non-reserved  
SENSITIVE   non-reserved  
SEQUENCE non-reserved reserved  
SERIAL non-reserved    
SERIALIZABLE non-reserved non-reserved non-reserved
SERVER_NAME   non-reserved non-reserved
SESSION non-reserved reserved reserved
SESSION_USER reserved reserved reserved
SET non-reserved reserved reserved
SETOF reserved    
SETS   reserved  
SHARE non-reserved    
SHOW reserved    
SIMILAR   non-reserved  
SIMPLE   non-reserved  
SIZE   reserved reserved
SMALLINT   reserved reserved
SOME reserved reserved reserved
SOURCE   non-reserved  
SPACE   reserved reserved
SPECIFIC   reserved  
SPECIFICTYPE   reserved  
SPECIFIC_NAME   non-reserved  
SQL   reserved reserved
SQLCODE     reserved
SQLERROR     reserved
SQLEXCEPTION   reserved  
SQLSTATE   reserved reserved
SQLWARNING   reserved  
START non-reserved reserved  
STATE   reserved  
STATEMENT non-reserved reserved  
STATIC   reserved  
STDIN non-reserved    
STDOUT non-reserved    
STRUCTURE   reserved  
STYLE   non-reserved  
SUBCLASS_ORIGIN   non-reserved non-reserved
SUBLIST   non-reserved  
SUBSTRING reserved non-reserved reserved
SUM   non-reserved reserved
SYMMETRIC   non-reserved  
SYSID non-reserved    
SYSTEM   non-reserved  
SYSTEM_USER   reserved reserved
TABLE reserved reserved reserved
TABLE_NAME   non-reserved non-reserved
TEMP non-reserved    
TEMPLATE non-reserved    
TEMPORARY non-reserved reserved reserved
TERMINATE   reserved  
THAN   reserved  
THEN reserved reserved reserved
TIME non-reserved reserved reserved
TIMESTAMP non-reserved reserved reserved
TIMEZONE_HOUR non-reserved reserved reserved
TIMEZONE_MINUTE non-reserved reserved reserved
TO reserved reserved reserved
TOAST non-reserved    
TRAILING reserved reserved reserved
TRANSACTION reserved reserved reserved
TRANSACTIONS_COMMITTED   non-reserved  
TRANSACTIONS_ROLLED_BACK   non-reserved  
TRANSACTION_ACTIVE   non-reserved  
TRANSFORM   non-reserved  
TRANSFORMS   non-reserved  
TRANSLATE   non-reserved reserved
TRANSLATION   reserved reserved
TREAT   reserved  
TRIGGER non-reserved reserved  
TRIGGER_CATALOG   non-reserved  
TRIGGER_NAME   non-reserved  
TRIGGER_SCHEMA   non-reserved  
TRIM reserved non-reserved reserved
TRUE reserved reserved reserved
TRUNCATE non-reserved    
TRUSTED non-reserved    
TYPE non-reserved non-reserved non-reserved
UNCOMMITTED   non-reserved non-reserved
UNDER   reserved  
UNION reserved reserved reserved
UNIQUE reserved reserved reserved
UNKNOWN   reserved reserved
UNLISTEN non-reserved    
UNNAMED   non-reserved non-reserved
UNNEST   reserved  
UNTIL non-reserved    
UPDATE non-reserved reserved reserved
UPPER   non-reserved reserved
USAGE   reserved reserved
USER reserved reserved reserved
USER_DEFINED_TYPE_CATALOG   non-reserved  
USER_DEFINED_TYPE_NAME   non-reserved  
USER_DEFINED_TYPE_SCHEMA   non-reserved  
USING reserved reserved reserved
VACUUM reserved    
VALID non-reserved    
VALUE   reserved reserved
VALUES non-reserved reserved reserved
VARCHAR reserved reserved reserved
VARIABLE   reserved  
VARYING non-reserved reserved reserved
VERBOSE reserved    
VERSION non-reserved    
VIEW non-reserved reserved reserved
WHEN reserved reserved reserved
WHENEVER   reserved reserved
WHERE reserved reserved reserved
WITH non-reserved reserved reserved
WITHOUT non-reserved reserved  
WORK non-reserved reserved reserved
WRITE   reserved reserved
YEAR non-reserved reserved reserved
ZONE non-reserved reserved reserved