Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
793 views
in Technique[技术] by (71.8m points)

postgresql - Maximum characters in labels (table names, columns etc)

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)?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 63 bytes. If this limit is problematic, it can be raised by changing the NAMEDATALEN constant in 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:

CREATE DOMAIN d_complement_activite_etablissement_or_even_loger_than_that AS text

I get what I ordered (tested on 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

Just Browsing Browsing

[5] html - How to create even cell spacing within a

1.4m articles

1.4m replys

5 comments

56.7k users

...