pg_get_keywords()

A function listing all SQL keywords

pg_get_keywords() is a system function returning all the SQL keywords recognized by PostgreSQL.

pg_get_keywords() was added in PostgreSQL 8.4.

Usage

pg_get_keywords () →
         setof record ( word text, catcode "char", barelabel boolean, catdesc text, baredesc text )

PostgreSQL 13 and earlier:

pg_get_keywords () → setof record ( word text, catcode "char", catdesc text )

Change history

Examples

Sample output from pg_get_keywords():

postgres=# SELECT * FROM pg_get_keywords() ORDER BY random() LIMIT 10;
    word     | catcode | barelabel |                   catdesc                    |     baredesc      
-------------+---------+-----------+----------------------------------------------+-------------------
 recursive   | U       | t         | unreserved                                   | can be bare label
 old         | U       | t         | unreserved                                   | can be bare label
 time        | C       | t         | unreserved (cannot be function or type name) | can be bare label
 implicit    | U       | t         | unreserved                                   | can be bare label
 publication | U       | t         | unreserved                                   | can be bare label
 variadic    | R       | t         | reserved                                     | can be bare label
 function    | U       | t         | unreserved                                   | can be bare label
 xmlroot     | C       | t         | unreserved (cannot be function or type name) | can be bare label
 execute     | U       | t         | unreserved                                   | can be bare label
 collation   | T       | t         | reserved (can be function or type name)      | can be bare label
(10 rows)

PostgreSQL 13 and earlier:

postgres=# SELECT * FROM pg_get_keywords() ORDER BY random() LIMIT 10;
      word       | catcode |                   catdesc                    
-----------------+---------+----------------------------------------------
 double          | U       | unreserved
 xmlparse        | C       | unreserved (cannot be function or type name)
 label           | U       | unreserved
 case            | R       | reserved
 current_time    | R       | reserved
 freeze          | T       | reserved (can be function or type name)
 substring       | C       | unreserved (cannot be function or type name)
 subscription    | U       | unreserved
 characteristics | U       | unreserved
 family          | U       | unreserved
(10 rows)

Categories

System function