How long can PostgreSQL table names be?

I am planning on using prefixes for a series of database names and need to make sure that I am not hitting the length limit. How long does PostgreSQL support for table names?

+3


source to share


1 answer


According to PostgreSQL documentation :

identifiers ... identify the names of tables, columns, or other database objects ...

The system uses no more than NAMEDATALEN-1

identifier bytes; longer names can be written in commands, but they will be truncated. The default NAMEDATALEN

is 64, so the maximum identifier length is 63 bytes.



You can see this limitation using the query suggested by this comment : SELECT length(repeat('xyzzy', 100)::NAME);

creates a 500 character string and sends it to PostgreSQL NAME

, then checks the length. The result is 63

.

+5


source







All Articles