NAMEDATALEN is a constant which defines the maximum length (in single byte characters) of database identifiers such as the names of databases, tables, columns etc. This value includes a trailing zero byte, meaning the actual maximum length is
NAMEDATALEN - 1.
NAMEDATALEN and ENUM
As well as database identifiers, the maximum length of
ENUM labels is also limited to
NAMEDATALEN - 1 bytes.
NAMEDATALEN is defined in src/include/pg_config_manual.h as:
/* * Maximum length for identifiers (e.g. table names, column names, * function names). Names actually are limited to one less byte than this, * because the length must include a trailing zero byte. * * Changing this requires an initdb. */ #define NAMEDATALEN 64
This 2017 pgsql-hackers thread: Revisiting NAMEDATALEN contains some insights into why it's unlikely
NAMEDATALEN will be extended in the future and discusses the (in)feasibility of making it a configurable parameter.