Appendix C. SQL Key Words

Table C-1 lists all tokens that are key words in the SQL standard and in PostgreSQL 7.4.8. Background information can be found in Section 4.1.1.

SQL distinguishes between reserved and non-reserved key words. According to the standard, 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. 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.) Even reserved key words are not completely reserved in PostgreSQL, but can be used as column labels (for example, SELECT 55 AS CHECK, even though CHECK is a reserved key word).

In Table C-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. Some key words that are otherwise non-reserved cannot be used as function or data type names and are marked accordingly. (Most of these words represent built-in functions or data types with special syntax. The function or type is still available but it cannot be redefined by the user.) Labeled "reserved" are those tokens that are only allowed as "AS" column label names (and perhaps in very few other contexts). Some reserved key words are allowable as names for functions; this is also shown in the table.

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 C-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 C-1. SQL Key Words

Key WordPostgreSQLSQL 99SQL 92
ABORTnon-reserved  
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
ARRAYreservedreserved 
ASreservedreservedreserved
ASCreservedreservedreserved
ASENSITIVE non-reserved 
ASSERTIONnon-reservedreservedreserved
ASSIGNMENTnon-reservednon-reserved 
ASYMMETRIC non-reserved 
ATnon-reservedreservedreserved
ATOMIC non-reserved 
AUTHORIZATIONreserved (can be function)reservedreserved
AVG non-reservedreserved
BACKWARDnon-reserved  
BEFOREnon-reservedreserved 
BEGINnon-reservedreservedreserved
BETWEENreserved (can be function)non-reservedreserved
BIGINTnon-reserved (cannot be function or type)  
BINARYreserved (can be function)reserved 
BITnon-reserved (cannot be function or type)reservedreserved
BITVAR non-reserved 
BIT_LENGTH non-reservedreserved
BLOB reserved 
BOOLEANnon-reserved (cannot be function or type)reserved 
BOTHreservedreservedreserved
BREADTH reserved 
BYnon-reservedreservedreserved
C non-reservednon-reserved
CACHEnon-reserved  
CALL reserved 
CALLEDnon-reservednon-reserved 
CARDINALITY non-reserved 
CASCADEnon-reservedreservedreserved
CASCADED reservedreserved
CASEreservedreservedreserved
CASTreservedreservedreserved
CATALOG reservedreserved
CATALOG_NAME non-reservednon-reserved
CHAINnon-reservednon-reserved 
CHARnon-reserved (cannot be function or type)reservedreserved
CHARACTERnon-reserved (cannot be function or type)reservedreserved
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  
CLASSnon-reservedreserved 
CLASS_ORIGIN non-reservednon-reserved
CLOB reserved 
CLOSEnon-reservedreservedreserved
CLUSTERnon-reserved  
COALESCEnon-reserved (cannot be function or type)non-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
CONVERSIONnon-reserved  
CONVERTnon-reserved (cannot be function or type)non-reservedreserved
COPYnon-reserved  
CORRESPONDING reservedreserved
COUNT non-reservedreserved
CREATEreservedreservedreserved
CREATEDBnon-reserved  
CREATEUSERnon-reserved  
CROSSreserved (can be function)reservedreserved
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
DEALLOCATEnon-reservedreservedreserved
DECnon-reserved (cannot be function or type)reservedreserved
DECIMALnon-reserved (cannot be function or type)reservedreserved
DECLAREnon-reservedreservedreserved
DEFAULTreservedreservedreserved
DEFAULTSnon-reserved  
DEFERRABLEreservedreservedreserved
DEFERREDnon-reservedreservedreserved
DEFINED non-reserved 
DEFINERnon-reservednon-reserved 
DELETEnon-reservedreservedreserved
DELIMITERnon-reserved  
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  
DOMAINnon-reservedreservedreserved
DOUBLEnon-reservedreservedreserved
DROPnon-reservedreservedreserved
DYNAMIC reserved 
DYNAMIC_FUNCTION non-reservednon-reserved
DYNAMIC_FUNCTION_CODE non-reserved 
EACHnon-reservedreserved 
ELSEreservedreservedreserved
ENCODINGnon-reserved  
ENCRYPTEDnon-reserved  
ENDreservedreservedreserved
END-EXEC reservedreserved
EQUALS reserved 
ESCAPEnon-reservedreservedreserved
EVERY reserved 
EXCEPTreservedreservedreserved
EXCEPTION reservedreserved
EXCLUDINGnon-reserved  
EXCLUSIVEnon-reserved  
EXEC reservedreserved
EXECUTEnon-reservedreservedreserved
EXISTING non-reserved 
EXISTSnon-reserved (cannot be function or type)non-reservedreserved
EXPLAINnon-reserved  
EXTERNALnon-reservedreservedreserved
EXTRACTnon-reserved (cannot be function or type)non-reservedreserved
FALSEreservedreservedreserved
FETCHnon-reservedreservedreserved
FINAL non-reserved 
FIRSTnon-reservedreservedreserved
FLOATnon-reserved (cannot be function or type)reservedreserved
FORreservedreservedreserved
FORCEnon-reserved  
FOREIGNreservedreservedreserved
FORTRAN non-reservednon-reserved
FORWARDnon-reserved  
FOUND reservedreserved
FREE reserved 
FREEZEreserved (can be function)  
FROMreservedreservedreserved
FULLreserved (can be function)reservedreserved
FUNCTIONnon-reservedreserved 
G non-reserved 
GENERAL reserved 
GENERATED non-reserved 
GET reservedreserved
GLOBALnon-reservedreservedreserved
GO reservedreserved
GOTO reservedreserved
GRANTreservedreservedreserved
GRANTED non-reserved 
GROUPreservedreservedreserved
GROUPING reserved 
HANDLERnon-reserved  
HAVINGreservedreservedreserved
HIERARCHY non-reserved 
HOLDnon-reservednon-reserved 
HOST reserved 
HOURnon-reservedreservedreserved
IDENTITY reservedreserved
IGNORE reserved 
ILIKEreserved (can be function)  
IMMEDIATEnon-reservedreservedreserved
IMMUTABLEnon-reserved  
IMPLEMENTATION non-reserved 
IMPLICITnon-reserved  
INreserved (can be function)reservedreserved
INCLUDINGnon-reserved  
INCREMENTnon-reserved  
INDEXnon-reserved  
INDICATOR reservedreserved
INFIX non-reserved 
INHERITSnon-reserved  
INITIALIZE reserved 
INITIALLYreservedreservedreserved
INNERreserved (can be function)reservedreserved
INOUTnon-reservedreserved 
INPUTnon-reservedreservedreserved
INSENSITIVEnon-reservednon-reservedreserved
INSERTnon-reservedreservedreserved
INSTANCE non-reserved 
INSTANTIABLE non-reserved 
INSTEADnon-reserved  
INTnon-reserved (cannot be function or type)reservedreserved
INTEGERnon-reserved (cannot be function or type)reservedreserved
INTERSECTreservedreservedreserved
INTERVALnon-reserved (cannot be function or type)reservedreserved
INTOreservedreservedreserved
INVOKERnon-reservednon-reserved 
ISreserved (can be function)reservedreserved
ISNULLreserved (can be function)  
ISOLATIONnon-reservedreservedreserved
ITERATE reserved 
JOINreserved (can be function)reservedreserved
K non-reserved 
KEYnon-reservedreservedreserved
KEY_MEMBER non-reserved 
KEY_TYPE non-reserved 
LANCOMPILERnon-reserved  
LANGUAGEnon-reservedreservedreserved
LARGE reserved 
LASTnon-reservedreservedreserved
LATERAL reserved 
LEADINGreservedreservedreserved
LEFTreserved (can be function)reservedreserved
LENGTH non-reservednon-reserved
LESS reserved 
LEVELnon-reservedreservedreserved
LIKEreserved (can be function)reservedreserved
LIMITreservedreserved 
LISTENnon-reserved  
LOADnon-reserved  
LOCALnon-reservedreservedreserved
LOCALTIMEreservedreserved 
LOCALTIMESTAMPreservedreserved 
LOCATIONnon-reserved  
LOCATOR reserved 
LOCKnon-reserved  
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
MOVEnon-reserved  
MUMPS non-reservednon-reserved
NAME non-reservednon-reserved
NAMESnon-reservedreservedreserved
NATIONALnon-reservedreservedreserved
NATURALreserved (can be function)reservedreserved
NCHARnon-reserved (cannot be function or type)reservedreserved
NCLOB reserved 
NEWreservedreserved 
NEXTnon-reservedreservedreserved
NOnon-reservedreservedreserved
NOCREATEDBnon-reserved  
NOCREATEUSERnon-reserved  
NONEnon-reserved (cannot be function or type)reserved 
NOTreservedreservedreserved
NOTHINGnon-reserved  
NOTIFYnon-reserved  
NOTNULLreserved (can be function)  
NULLreservedreservedreserved
NULLABLE non-reservednon-reserved
NULLIFnon-reserved (cannot be function or type)non-reservedreserved
NUMBER non-reservednon-reserved
NUMERICnon-reserved (cannot be function or type)reservedreserved
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 
OUTnon-reservedreserved 
OUTERreserved (can be function)reservedreserved
OUTPUT reservedreserved
OVERLAPSreserved (can be function)non-reservedreserved
OVERLAYnon-reserved (cannot be function or type)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  
PLACINGreserved  
PLI non-reservednon-reserved
POSITIONnon-reserved (cannot be function or type)non-reservedreserved
POSTFIX reserved 
PRECISIONnon-reservedreservedreserved
PREFIX reserved 
PREORDER reserved 
PREPAREnon-reservedreservedreserved
PRESERVEnon-reservedreservedreserved
PRIMARYreservedreservedreserved
PRIORnon-reservedreservedreserved
PRIVILEGESnon-reservedreservedreserved
PROCEDURALnon-reserved  
PROCEDUREnon-reservedreservedreserved
PUBLIC reservedreserved
READnon-reservedreservedreserved
READS reserved 
REALnon-reserved (cannot be function or type)reservedreserved
RECHECKnon-reserved  
RECURSIVE reserved 
REF reserved 
REFERENCESreservedreservedreserved
REFERENCING reserved 
REINDEXnon-reserved  
RELATIVEnon-reservedreservedreserved
RENAMEnon-reserved  
REPEATABLE non-reservednon-reserved
REPLACEnon-reserved  
RESETnon-reserved  
RESTARTnon-reserved  
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
RIGHTreserved (can be function)reservedreserved
ROLE reserved 
ROLLBACKnon-reservedreservedreserved
ROLLUP reserved 
ROUTINE reserved 
ROUTINE_CATALOG non-reserved 
ROUTINE_NAME non-reserved 
ROUTINE_SCHEMA non-reserved 
ROWnon-reserved (cannot be function or type)reserved 
ROWSnon-reservedreservedreserved
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
SECURITYnon-reservednon-reserved 
SELECTreservedreservedreserved
SELF non-reserved 
SENSITIVE non-reserved 
SEQUENCEnon-reservedreserved 
SERIALIZABLEnon-reservednon-reservednon-reserved
SERVER_NAME non-reservednon-reserved
SESSIONnon-reservedreservedreserved
SESSION_USERreservedreservedreserved
SETnon-reservedreservedreserved
SETOFnon-reserved (cannot be function or type)  
SETS reserved 
SHAREnon-reserved  
SHOWnon-reserved  
SIMILARreserved (can be function)non-reserved 
SIMPLEnon-reservednon-reserved 
SIZE reservedreserved
SMALLINTnon-reserved (cannot be function or type)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 
STABLEnon-reserved  
STARTnon-reservedreserved 
STATE reserved 
STATEMENTnon-reservedreserved 
STATIC reserved 
STATISTICSnon-reserved  
STDINnon-reserved  
STDOUTnon-reserved  
STORAGEnon-reserved  
STRICTnon-reserved  
STRUCTURE reserved 
STYLE non-reserved 
SUBCLASS_ORIGIN non-reservednon-reserved
SUBLIST non-reserved 
SUBSTRINGnon-reserved (cannot be function or type)non-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-reserved (cannot be function or type)reservedreserved
TIMESTAMPnon-reserved (cannot be function or type)reservedreserved
TIMEZONE_HOUR reservedreserved
TIMEZONE_MINUTE reservedreserved
TOreservedreservedreserved
TOASTnon-reserved  
TRAILINGreservedreservedreserved
TRANSACTIONnon-reservedreservedreserved
TRANSACTIONS_COMMITTED non-reserved 
TRANSACTIONS_ROLLED_BACK non-reserved 
TRANSACTION_ACTIVE non-reserved 
TRANSFORM non-reserved 
TRANSFORMS non-reserved 
TRANSLATE non-reservedreserved
TRANSLATION reservedreserved
TREATnon-reserved (cannot be function or type)reserved 
TRIGGERnon-reservedreserved 
TRIGGER_CATALOG non-reserved 
TRIGGER_NAME non-reserved 
TRIGGER_SCHEMA non-reserved 
TRIMnon-reserved (cannot be function or type)non-reservedreserved
TRUEreservedreservedreserved
TRUNCATEnon-reserved  
TRUSTEDnon-reserved  
TYPEnon-reservednon-reservednon-reserved
UNCOMMITTED non-reservednon-reserved
UNDER reserved 
UNENCRYPTEDnon-reserved  
UNIONreservedreservedreserved
UNIQUEreservedreservedreserved
UNKNOWNnon-reservedreservedreserved
UNLISTENnon-reserved  
UNNAMED non-reservednon-reserved
UNNEST reserved 
UNTILnon-reserved  
UPDATEnon-reservedreservedreserved
UPPER non-reservedreserved
USAGEnon-reservedreservedreserved
USERreservedreservedreserved
USER_DEFINED_TYPE_CATALOG non-reserved 
USER_DEFINED_TYPE_NAME non-reserved 
USER_DEFINED_TYPE_SCHEMA non-reserved 
USINGreservedreservedreserved
VACUUMnon-reserved  
VALIDnon-reserved  
VALIDATORnon-reserved  
VALUE reservedreserved
VALUESnon-reservedreservedreserved
VARCHARnon-reserved (cannot be function or type)reservedreserved
VARIABLE reserved 
VARYINGnon-reservedreservedreserved
VERBOSEreserved (can be function)  
VERSIONnon-reserved  
VIEWnon-reservedreservedreserved
VOLATILEnon-reserved  
WHENreservedreservedreserved
WHENEVER reservedreserved
WHEREreservedreservedreserved
WITHnon-reservedreservedreserved
WITHOUTnon-reservedreserved 
WORKnon-reservedreservedreserved
WRITEnon-reservedreservedreserved
YEARnon-reservedreservedreserved
ZONEnon-reservedreservedreserved