PostgreSQL table 名称可以有多长?

How long can PostgreSQL table names be?

我打算为一系列数据库名称使用前缀,并且需要确保我没有 运行 长度限制。 PostgreSQL 支持多长的 table 名称?

根据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.

您可以使用 this comment 建议的查询查看此限制:SELECT length(repeat('xyzzy', 100)::NAME); 创建一个 500 个字符的字符串并将其转换为 PostgreSQL 的 NAME 类型,然后检查长度。结果是 63.