加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

数据库 – PostgreSQL字符变长限制

发布时间:2020-12-12 16:11:17 所属栏目:MsSql教程 来源:网络整理
导读:我在PostgreSQL中使用字符变化的数据类型. 我在PostgreSQL手册中找不到这个信息. 字符变化数据类型中字符的最大限制是多少? 解决方法 参考 documentation,对varchar(n)类型定义没有明确的限制.但: … In any case,the longest possible character string th
我在PostgreSQL中使用字符变化的数据类型.
我在PostgreSQL手册中找不到这个信息.
字符变化数据类型中字符的最大限制是多少?

解决方法

参考 documentation,对varchar(n)类型定义没有明确的限制.但:


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 very useful to change this
because with multibyte character
encodings the number of characters and
bytes can be quite different anyway.
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.)

另请注意:

Tip: There is no performance difference among these three types,apart from increased storage space when using the blank-padded type,and a few extra CPU cycles to check the length when storing into a length-constrained column. While character(n) has performance advantages in some other database systems,there is no such advantage in PostgreSQL; in fact character(n) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读