I'm planning to use prefixes for a series of database names and need to make sure I don't run into a length limit. What length of table names does PostgreSQL support?
The maximum length of a table name is 64 characters long according to MySQl version 8.0.
3) PostgreSQL Text Data Type The PostgreSQL Text data type is used to keep the character of infinite length. And it can hold a string with a maximum length of 65,535 bytes.
Table names must follow the rules for SQL Server identifiers, and be less than 128 characters.
Column names Must be less than the maximum length of 59 characters. Columns that exceed this limit will be rejected by PostgreSQL.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With