Fre*_*ruz 41 postgresql varchar
postgresql 中各种数据类型的大小限制是多少?我在某处看到 for character varying(n),varchar(n) n必须在 1 到 10485760 之间。这是真的吗?
什么是有效的尺寸character(n),char(n)和text?
kli*_*lin 49
Postgres 中有限字符类型(例如 varchar(n))的最大大小为 10485760。您可以通过这种方式检查:
create table test(id serial primary key, str varchar(10485761));
ERROR: length for type varchar cannot exceed 10485760
Run Code Online (Sandbox Code Playgroud)
该限制在以下源代码片段(htup_details.h)中定义,但在官方文档中没有明确提及:
/*
* MaxAttrSize is a somewhat arbitrary upper limit on the declared size of
* data fields of char(n) and similar types. It need not have anything
* directly to do with the *actual* upper limit of varlena values, which
* is currently 1Gb (see TOAST structures in postgres.h). I've set it
* at 10Mb which seems like a reasonable number --- tgl 8/6/00.
*/
#define MaxAttrSize (10 * 1024 * 1024)
Run Code Online (Sandbox Code Playgroud)
可变无限长度类型(文本、varchar)的最大字符数未定义。所有字符串类型都有字节大小限制:
在任何情况下,可以存储的最长字符串大约是 1 GB。
| 归档时间: |
|
| 查看次数: |
83878 次 |
| 最近记录: |