postgresql 标签中的最大字符数(表名、列等)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8213127/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maximum characters in labels (table names, columns etc)
提问by Florin Vistig
Hope this question wasn't asked before. Does anyone know the character limit for domain names? For example if I write this:
希望以前没有问过这个问题。有人知道域名的字数限制吗?例如,如果我这样写:
CREATE DOMAIN d_complement_activite_etablissement AS character varying
it will create a domain with the name:
它将创建一个域名:
d_complement_activite_etabliss
(Yeah, I know how to count, but I want some more info on the subject).
(是的,我知道如何数数,但我想了解有关该主题的更多信息)。
Is there a command that can change this maximum length? Is this length the same for other names (columns, tables etc)?
是否有可以更改此最大长度的命令?对于其他名称(列、表等),此长度是否相同?
回答by Erwin Brandstetter
You ask:
你问:
Is there a command that can change this maximum length? Is this length the same for other names (columns, tables etc)?
是否有可以更改此最大长度的命令?对于其他名称(列、表等),此长度是否相同?
The manual answers here:
该手册的答案在这里:
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 63bytes. If this limit is problematic, it can be raised by changing theNAMEDATALEN
constant insrc/include/pg_config_manual.h
.
系统使用
NAMEDATALEN-1
的标识符不超过字节;可以在命令中写入更长的名称,但它们将被截断。默认情况下,NAMEDATALEN
为 64,因此最大标识符长度为63字节。如果此限制有问题,可以通过更改 中的NAMEDATALEN
常量来提高src/include/pg_config_manual.h
。
Bold emphasis mine.
大胆强调我的。
The only way to change it is to hack the source code and recompile PostgreSQL.
Domain names are identifiers like any other. When I execute:
改变它的唯一方法是破解源代码并重新编译 PostgreSQL。
域名是与其他任何标识符一样的标识符。当我执行:
CREATE DOMAIN d_complement_activite_etablissement_or_even_loger_than_that AS text
I get what I ordered (tested on PostgreSQL 8.4 - 11):
我得到了我订购的东西(在 PostgreSQL 8.4 - 11 上测试过):
d_complement_activite_etablissement_or_even_loger_than_that
Ergo: there must be some other piece of software between you and your database cropping the name.
因此:您和您的数据库之间必须有其他一些软件来裁剪名称。