How long can PostgreSQL table names be?

According to the PostgreSQL documentation:

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

The system uses no more than NAMEDATALEN-1 bytes of an identifier; longer names can be written in commands, but they will be truncated. By default, NAMEDATALEN is 64 so the maximum identifier length is 63 bytes.

You can see this limit using the query suggested by this comment: SELECT length(repeat('xyzzy', 100)::NAME); creates a 500-character string and casts it to PostgreSQL’s NAME type, then checks the length. The result is 63.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)