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 is configured at compile time. If changed, initdb is required to initialise a new database instance with the changed value.
The standard value is:
Determining the value of NAMEDATALEN
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.