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 WordPostgreSQLSQL 99SQL 92
ABORTreserved  
ABS non-reserved 
ABSOLUTEnon-reservedreservedreserved
ACCESSnon-reserved  
ACTIONnon-reservedreservedreserved
ADA non-reservednon-reserved
ADDnon-reservedreservedreserved
ADMIN reserved 
AFTERnon-reservedreserved 
AGGREGATEnon-reservedreserved 
ALIAS reserved 
ALLreservedreservedreserved
ALLOCATE reservedreserved
ALTERnon-reservedreservedreserved
ANALYSEreserved  
ANALYZEreserved  
ANDreservedreservedreserved
ANYreservedreservedreserved
ARE reservedreserved
ARRAY reserved 
ASreservedreservedreserved
ASCreservedreservedreserved
ASENSITIVE non-reserved 
ASSERTION reservedreserved
ASSIGNMENT non-reserved 
ASYMMETRIC non-reserved 
ATnon-reservedreservedreserved
ATOMIC non-reserved 
AUTHORIZATION reservedreserved
AVG non-reservedreserved
BACKWARDnon-reserved  
BEFOREnon-reservedreserved 
BEGINnon-reservedreservedreserved
BETWEENreservednon-reservedreserved
BINARYreservedreserved 
BITreservedreservedreserved
BITVAR non-reserved 
BIT_LENGTH non-reservedreserved
BLOB reserved 
BOOLEAN reserved 
BOTHreservedreservedreserved
BREADTH reserved 
BYnon-reservedreservedreserved
C non-reservednon-reserved
CACHEnon-reserved  
CALL reserved 
CALLED non-reserved 
CARDINALITY non-reserved 
CASCADEnon-reservedreservedreserved
CASCADED reservedreserved
CASEreservedreservedreserved
CASTreservedreservedreserved
CATALOG reservedreserved
CATALOG_NAME non-reservednon-reserved
CHAINnon-reservednon-reserved 
CHARreservedreservedreserved
CHARACTERreservedreservedreserved
CHARACTERISTICSnon-reserved  
CHARACTER_LENGTH non-reservedreserved
CHARACTER_SET_CATALOG non-reservednon-reserved
CHARACTER_SET_NAME non-reservednon-reserved
CHARACTER_SET_SCHEMA non-reservednon-reserved
CHAR_LENGTH non-reservedreserved
CHECKreservedreservedreserved
CHECKED non-reserved 
CHECKPOINTnon-reserved  
CLASS reserved 
CLASS_ORIGIN non-reservednon-reserved
CLOB reserved 
CLOSEnon-reservedreservedreserved
CLUSTERreserved  
COALESCEreservednon-reservedreserved
COBOL non-reservednon-reserved
COLLATEreservedreservedreserved
COLLATION reservedreserved
COLLATION_CATALOG non-reservednon-reserved
COLLATION_NAME non-reservednon-reserved
COLLATION_SCHEMA non-reservednon-reserved
COLUMNreservedreservedreserved
COLUMN_NAME non-reservednon-reserved
COMMAND_FUNCTION non-reservednon-reserved
COMMAND_FUNCTION_CODE non-reserved 
COMMENTnon-reserved  
COMMITnon-reservedreservedreserved
COMMITTEDnon-reservednon-reservednon-reserved
COMPLETION reserved 
CONDITION_NUMBER non-reservednon-reserved
CONNECT reservedreserved
CONNECTION reservedreserved
CONNECTION_NAME non-reservednon-reserved
CONSTRAINTreservedreservedreserved
CONSTRAINTSnon-reservedreservedreserved
CONSTRAINT_CATALOG non-reservednon-reserved
CONSTRAINT_NAME non-reservednon-reserved
CONSTRAINT_SCHEMA non-reservednon-reserved
CONSTRUCTOR reserved 
CONTAINS non-reserved 
CONTINUE reservedreserved
CONVERT non-reservedreserved
COPYreserved  
CORRESPONDING reservedreserved
COUNT non-reservedreserved
CREATEnon-reservedreservedreserved
CREATEDBnon-reserved  
CREATEUSERnon-reserved  
CROSSreservedreservedreserved
CUBE reserved 
CURRENT reservedreserved
CURRENT_DATEreservedreservedreserved
CURRENT_PATH reserved 
CURRENT_ROLE reserved 
CURRENT_TIMEreservedreservedreserved
CURRENT_TIMESTAMPreservedreservedreserved
CURRENT_USERreservedreservedreserved
CURSORnon-reservedreservedreserved
CURSOR_NAME non-reservednon-reserved
CYCLEnon-reservedreserved 
DATA reservednon-reserved
DATABASEnon-reserved  
DATE reservedreserved
DATETIME_INTERVAL_CODE non-reservednon-reserved
DATETIME_INTERVAL_PRECISION non-reservednon-reserved
DAYnon-reservedreservedreserved
DEALLOCATE reservedreserved
DECreservedreservedreserved
DECIMALreservedreservedreserved
DECLAREnon-reservedreservedreserved
DEFAULTreservedreservedreserved
DEFERRABLEreservedreservedreserved
DEFERREDnon-reservedreservedreserved
DEFINED non-reserved 
DEFINER non-reserved 
DELETEnon-reservedreservedreserved
DELIMITERSnon-reserved  
DEPTH reserved 
DEREF reserved 
DESCreservedreservedreserved
DESCRIBE reservedreserved
DESCRIPTOR reservedreserved
DESTROY reserved 
DESTRUCTOR reserved 
DETERMINISTIC reserved 
DIAGNOSTICS reservedreserved
DICTIONARY reserved 
DISCONNECT reservedreserved
DISPATCH non-reserved 
DISTINCTreservedreservedreserved
DOreserved  
DOMAIN reservedreserved
DOUBLEnon-reservedreservedreserved
DROPnon-reservedreservedreserved
DYNAMIC reserved 
DYNAMIC_FUNCTION non-reservednon-reserved
DYNAMIC_FUNCTION_CODE non-reserved 
EACHnon-reservedreserved 
ELSEreservedreservedreserved
ENCODINGnon-reserved  
ENDreservedreservedreserved
END-EXEC reservedreserved
EQUALS reserved 
ESCAPEnon-reservedreservedreserved
EVERY reserved 
EXCEPTreservedreservedreserved
EXCEPTION reservedreserved
EXCLUSIVEnon-reserved  
EXEC reservedreserved
EXECUTEnon-reservedreservedreserved
EXISTING non-reserved 
EXISTSreservednon-reservedreserved
EXPLAINreserved  
EXTENDreserved  
EXTERNAL reservedreserved
EXTRACTreservednon-reservedreserved
FALSEreservedreservedreserved
FETCHnon-reservedreservedreserved
FINAL non-reserved 
FIRST reservedreserved
FLOATreservedreservedreserved
FORreservedreservedreserved
FORCEnon-reserved  
FOREIGNreservedreservedreserved
FORTRAN non-reservednon-reserved
FORWARDnon-reserved  
FOUND reservedreserved
FREE reserved 
FROMreservedreservedreserved
FULLreservedreservedreserved
FUNCTIONnon-reservedreserved 
G non-reserved 
GENERAL reserved 
GENERATED non-reserved 
GET reservedreserved
GLOBALreservedreservedreserved
GO reservedreserved
GOTO reservedreserved
GRANTnon-reservedreservedreserved
GRANTED non-reserved 
GROUPreservedreservedreserved
GROUPING reserved 
HANDLERnon-reserved  
HAVINGreservedreservedreserved
HIERARCHY non-reserved 
HOLD non-reserved 
HOST reserved 
HOURnon-reservedreservedreserved
IDENTITY reservedreserved
IGNORE reserved 
ILIKEreserved  
IMMEDIATEnon-reservedreservedreserved
IMPLEMENTATION non-reserved 
INreservedreservedreserved
INCREMENTnon-reserved  
INDEXnon-reserved  
INDICATOR reservedreserved
INFIX non-reserved 
INHERITSnon-reserved  
INITIALIZE reserved 
INITIALLYreservedreservedreserved
INNERreservedreservedreserved
INOUTreservedreserved 
INPUT reservedreserved
INSENSITIVEnon-reservednon-reservedreserved
INSERTnon-reservedreservedreserved
INSTANCE non-reserved 
INSTANTIABLE non-reserved 
INSTEADnon-reserved  
INT reservedreserved
INTEGER reservedreserved
INTERSECTreservedreservedreserved
INTERVALnon-reservedreservedreserved
INTOreservedreservedreserved
INVOKER non-reserved 
ISreservedreservedreserved
ISNULLreserved  
ISOLATIONnon-reservedreservedreserved
ITERATE reserved 
JOINreservedreservedreserved
K non-reserved 
KEYnon-reservedreservedreserved
KEY_MEMBER non-reserved 
KEY_TYPE non-reserved 
LANCOMPILERnon-reserved  
LANGUAGEnon-reservedreservedreserved
LARGE reserved 
LAST reservedreserved
LATERAL reserved 
LEADINGreservedreservedreserved
LEFTreservedreservedreserved
LENGTH non-reservednon-reserved
LESS reserved 
LEVELnon-reservedreservedreserved
LIKEreservedreservedreserved
LIMITreservedreserved 
LISTENreserved  
LOADreserved  
LOCALreservedreservedreserved
LOCALTIME reserved 
LOCALTIMESTAMP reserved 
LOCATIONnon-reserved  
LOCATOR reserved 
LOCKreserved  
LOWER non-reservedreserved
M non-reserved 
MAP reserved 
MATCHnon-reservedreservedreserved
MAX non-reservedreserved
MAXVALUEnon-reserved  
MESSAGE_LENGTH non-reservednon-reserved
MESSAGE_OCTET_LENGTH non-reservednon-reserved
MESSAGE_TEXT non-reservednon-reserved
METHOD non-reserved 
MIN non-reservedreserved
MINUTEnon-reservedreservedreserved
MINVALUEnon-reserved  
MOD non-reserved 
MODEnon-reserved  
MODIFIES reserved 
MODIFY reserved 
MODULE reservedreserved
MONTHnon-reservedreservedreserved
MORE non-reservednon-reserved
MOVEreserved  
MUMPS non-reservednon-reserved
NAME non-reservednon-reserved
NAMESnon-reservedreservedreserved
NATIONALnon-reservedreservedreserved
NATURALreservedreservedreserved
NCHARreservedreservedreserved
NCLOB reserved 
NEWreservedreserved 
NEXTnon-reservedreservedreserved
NOnon-reservedreservedreserved
NOCREATEDBnon-reserved  
NOCREATEUSERnon-reserved  
NONEnon-reservedreserved 
NOTreservedreservedreserved
NOTHINGnon-reserved  
NOTIFYnon-reserved  
NOTNULLreserved  
NULLreservedreservedreserved
NULLABLE non-reservednon-reserved
NULLIFreservednon-reservedreserved
NUMBER non-reservednon-reserved
NUMERICreservedreservedreserved
OBJECT reserved 
OCTET_LENGTH non-reservedreserved
OFnon-reservedreservedreserved
OFFreservedreserved 
OFFSETreserved  
OIDSnon-reserved  
OLDreservedreserved 
ONreservedreservedreserved
ONLYreservedreservedreserved
OPEN reservedreserved
OPERATION reserved 
OPERATORnon-reserved  
OPTIONnon-reservedreservedreserved
OPTIONS non-reserved 
ORreservedreservedreserved
ORDERreservedreservedreserved
ORDINALITY reserved 
OUTreservedreserved 
OUTERreservedreservedreserved
OUTPUT reservedreserved
OVERLAPSreservednon-reservedreserved
OVERLAY non-reserved 
OVERRIDING non-reserved 
OWNERnon-reserved  
PAD reservedreserved
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 
PARTIALnon-reservedreservedreserved
PASCAL non-reservednon-reserved
PASSWORDnon-reserved  
PATHnon-reservedreserved 
PENDANTnon-reserved  
PLI non-reservednon-reserved
POSITIONreservednon-reservedreserved
POSTFIX reserved 
PRECISIONreservedreservedreserved
PREFIX reserved 
PREORDER reserved 
PREPARE reservedreserved
PRESERVE reservedreserved
PRIMARYreservedreservedreserved
PRIORnon-reservedreservedreserved
PRIVILEGESnon-reservedreservedreserved
PROCEDURALnon-reserved  
PROCEDUREnon-reservedreservedreserved
PUBLICreservedreservedreserved
READnon-reservedreservedreserved
READS reserved 
REAL reservedreserved
RECURSIVE reserved 
REF reserved 
REFERENCESreservedreservedreserved
REFERENCING reserved 
REINDEXnon-reserved  
RELATIVEnon-reservedreservedreserved
RENAMEnon-reserved  
REPEATABLE non-reservednon-reserved
RESETreserved  
RESTRICTnon-reservedreservedreserved
RESULT reserved 
RETURN reserved 
RETURNED_LENGTH non-reservednon-reserved
RETURNED_OCTET_LENGTH non-reservednon-reserved
RETURNED_SQLSTATE non-reservednon-reserved
RETURNSnon-reservedreserved 
REVOKEnon-reservedreservedreserved
RIGHTreservedreservedreserved
ROLE reserved 
ROLLBACKnon-reservedreservedreserved
ROLLUP reserved 
ROUTINE reserved 
ROUTINE_CATALOG non-reserved 
ROUTINE_NAME non-reserved 
ROUTINE_SCHEMA non-reserved 
ROWnon-reservedreserved 
ROWS reservedreserved
ROW_COUNT non-reservednon-reserved
RULEnon-reserved  
SAVEPOINT reserved 
SCALE non-reservednon-reserved
SCHEMAnon-reservedreservedreserved
SCHEMA_NAME non-reservednon-reserved
SCOPE reserved 
SCROLLnon-reservedreservedreserved
SEARCH reserved 
SECONDnon-reservedreservedreserved
SECTION reservedreserved
SECURITY non-reserved 
SELECTreservedreservedreserved
SELF non-reserved 
SENSITIVE non-reserved 
SEQUENCEnon-reservedreserved 
SERIALnon-reserved  
SERIALIZABLEnon-reservednon-reservednon-reserved
SERVER_NAME non-reservednon-reserved
SESSIONnon-reservedreservedreserved
SESSION_USERreservedreservedreserved
SETnon-reservedreservedreserved
SETOFreserved  
SETS reserved 
SHAREnon-reserved  
SHOWreserved  
SIMILAR non-reserved 
SIMPLE non-reserved 
SIZE reservedreserved
SMALLINT reservedreserved
SOMEreservedreservedreserved
SOURCE non-reserved 
SPACE reservedreserved
SPECIFIC reserved 
SPECIFICTYPE reserved 
SPECIFIC_NAME non-reserved 
SQL reservedreserved
SQLCODE  reserved
SQLERROR  reserved
SQLEXCEPTION reserved 
SQLSTATE reservedreserved
SQLWARNING reserved 
STARTnon-reservedreserved 
STATE reserved 
STATEMENTnon-reservedreserved 
STATIC reserved 
STDINnon-reserved  
STDOUTnon-reserved  
STRUCTURE reserved 
STYLE non-reserved 
SUBCLASS_ORIGIN non-reservednon-reserved
SUBLIST non-reserved 
SUBSTRINGreservednon-reservedreserved
SUM non-reservedreserved
SYMMETRIC non-reserved 
SYSIDnon-reserved  
SYSTEM non-reserved 
SYSTEM_USER reservedreserved
TABLEreservedreservedreserved
TABLE_NAME non-reservednon-reserved
TEMPnon-reserved  
TEMPLATEnon-reserved  
TEMPORARYnon-reservedreservedreserved
TERMINATE reserved 
THAN reserved 
THENreservedreservedreserved
TIMEnon-reservedreservedreserved
TIMESTAMPnon-reservedreservedreserved
TIMEZONE_HOURnon-reservedreservedreserved
TIMEZONE_MINUTEnon-reservedreservedreserved
TOreservedreservedreserved
TOASTnon-reserved  
TRAILINGreservedreservedreserved
TRANSACTIONreservedreservedreserved
TRANSACTIONS_COMMITTED non-reserved 
TRANSACTIONS_ROLLED_BACK non-reserved 
TRANSACTION_ACTIVE non-reserved 
TRANSFORM non-reserved 
TRANSFORMS non-reserved 
TRANSLATE non-reservedreserved
TRANSLATION reservedreserved
TREAT reserved 
TRIGGERnon-reservedreserved 
TRIGGER_CATALOG non-reserved 
TRIGGER_NAME non-reserved 
TRIGGER_SCHEMA non-reserved 
TRIMreservednon-reservedreserved
TRUEreservedreservedreserved
TRUNCATEnon-reserved  
TRUSTEDnon-reserved  
TYPEnon-reservednon-reservednon-reserved
UNCOMMITTED non-reservednon-reserved
UNDER reserved 
UNIONreservedreservedreserved
UNIQUEreservedreservedreserved
UNKNOWN reservedreserved
UNLISTENnon-reserved  
UNNAMED non-reservednon-reserved
UNNEST reserved 
UNTILnon-reserved  
UPDATEnon-reservedreservedreserved
UPPER non-reservedreserved
USAGE reservedreserved
USERreservedreservedreserved
USER_DEFINED_TYPE_CATALOG non-reserved 
USER_DEFINED_TYPE_NAME non-reserved 
USER_DEFINED_TYPE_SCHEMA non-reserved 
USINGreservedreservedreserved
VACUUMreserved  
VALIDnon-reserved  
VALUE reservedreserved
VALUESnon-reservedreservedreserved
VARCHARreservedreservedreserved
VARIABLE reserved 
VARYINGnon-reservedreservedreserved
VERBOSEreserved  
VERSIONnon-reserved  
VIEWnon-reservedreservedreserved
WHENreservedreservedreserved
WHENEVER reservedreserved
WHEREreservedreservedreserved
WITHnon-reservedreservedreserved
WITHOUTnon-reservedreserved 
WORKnon-reservedreservedreserved
WRITE reservedreserved
YEARnon-reservedreservedreserved
ZONEnon-reservedreservedreserved