postgresql 我们可以用PostgreSQL数据库创建一列字符变化(MAX)吗

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36279977/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:13:02  来源:igfitidea点击:

Can we create a column of character varying(MAX) with PostgreSQL database

postgresqlpostgresql-9.3sqldatatypes

提问by Samir

I am unable to set the max size of particular column in PostgreSQL with MAXkeyword. Is there any keyword like MAX. If not how can we create the column with the maximum size?

我无法使用MAX关键字设置 PostgreSQL 中特定列的最大大小。有没有像MAX. 如果不是,我们如何创建最大尺寸的列?

回答by a_horse_with_no_name

If you want to created an "unbounded" varcharcolumn just use varcharwithout a length restriction.

如果您想创建一个“无界”varchar列,只需使用varchar没有长度限制。

From the manual:

从手册:

If character varying is used without length specifier, the type accepts strings of any size

如果在没有长度说明符的情况下使用字符变化,则该类型接受任何大小的字符串

So you can use:

所以你可以使用:

create table foo
( 
  unlimited  varchar
);

Another alternative is to use text:

另一种选择是使用text

create table foo
( 
  unlimited text
);

More details about character data types are in the manual:
http://www.postgresql.org/docs/current/static/datatype-character.html

有关字符数据类型的更多详细信息,请参见手册:http:
//www.postgresql.org/docs/current/static/datatype-character.html