Text在PostgreSQL中的最大长度

今天,和mentor一起review数据库的设计稿的时候,领导提了一个问题,text在PostgreSQL中最大能支持的长度是多少,之前只知道Text是不定长的,没有考虑过长度问题,所以特的查了一下官方文档。
在任何情况下,能被存储的最长的字符串是1GB(数据类型定义中n能允许的最大值比这个值要小。修改它没有用处,因为对于多字节字符编码来说,字符的数量和字节数可能完全不同。如果你想要存储没有指定上限的长串,使用text或没有长度声明的character varying,而不是给出一个任意长度限制)。

In any case, the longest possible character string that can be stored is about 1 GB. (The maximum value that will be allowed for n in the data type declaration is less than that. It wouldn’t be useful to change this because with multibyte character encodings the number of characters and bytes can be quite different. If you desire to store long strings with no specific upper limit, use text or character varying without a length specifier, rather than making up an arbitrary length limit.)

参考
http://www.postgres.cn/docs/12/datatype-character.html
https://www.postgresql.org/docs/12/datatype-character.html

本文链接:https://my.lmcjl.com/post/9569.html

展开阅读全文

4 评论

留下您的评论.