Advanced Server Keywords v12

A keyword is a word that is recognized by the Advanced Server parser as having a special meaning or association. You can use the pg_get_keywords() function to retrieve an up-to-date list of the Advanced Server keywords:

acctg=#
acctg=# SELECT * FROM pg_get_keywords();
        word         | catcode |          catdesc
---------------------+---------+---------------------------------
 abort               | U       | unreserved
 absolute            | U       | unreserved
 access              | U       | unreserved
...

pg_get_keywords returns a table containing the keywords recognized by Advanced Server:

  • The word column displays the keyword.
  • The catcode column displays a category code.
  • The catdesc column displays a brief description of the category to which the keyword belongs.

Note that any character can be used in an identifier if the name is enclosed in double quotes. You can selectively query the pg_get_keywords() function to retrieve an up-to-date list of the Advanced Server keywords that belong to a specific category:

SELECT * FROM pg_get_keywords() WHERE catcode = 'code';

Where code is:

R - The word is reserved. Reserved keywords may never be used as an identifier, they are reserved for use by the server.

U - The word is unreserved. Unreserved words are used internally in some contexts, but may be used as a name for a database object.

T - The word is used internally, but may be used as a name for a function or type.

C - The word is used internally, and may not be used as a name for a function or type.

For more information about Advanced Server identifiers and keywords, see to the PostgreSQL core documentation at:

https://www.postgresql.org/docs/12/static/sql-syntax-lexical.html