string – PostgreSQL:文本和varchar之间的差异(字符变化)

string – PostgreSQL:文本和varchar之间的差异(字符变化),第1张

概述文本数据类型和字符变化(varchar)数据类型之间有什么区别? 根据the documentation If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension. 和 In addition, P 文本数据类型和字符变化(varchar)数据类型之间有什么区别?

根据the documentation

If character varying is used without length specifIEr,the type accepts strings of any size. The latter is a Postgresql extension.

In addition,Postgresql provIDes the text type,which stores strings of any length. Although the type text is not in the sql standard,several other sql database management systems have it as well.

那么有什么区别?

没有区别,在引擎盖下它是所有varlena( variable length array)。

检查这篇文章从Depesz:http://www.depesz.com/index.php/2010/03/02/charx-vs-varcharx-vs-varchar-vs-text/

几个亮点:

To sum it all up:

char(n) – takes too much space when dealing with values shorter than n,and can lead to subtle errors because of adding trailing
spaces,plus it is problematic to change the limit varchar(n) – it’s problematic to change the limit in live environment varchar – just like text text – for me a winner – over (n) data types because it lacks their problems,and over varchar – because it has distinct name

本文做了详细的测试,以显示插入和选择的性能为所有4种数据类型是类似的。它还需要详细了解在需要时限制长度的替代方法。基于函数的约束或域提供了长度约束的即时增加的优点,并且在减少字符串长度约束是罕见的基础上,depesz得出结论,其中之一通常是长度限制的最佳选择。

总结

以上是内存溢出为你收集整理的string – PostgreSQL:文本和varchar之间的差异(字符变化)全部内容,希望文章能够帮你解决string – PostgreSQL:文本和varchar之间的差异(字符变化)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/1173449.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-02
下一篇2022-06-02

发表评论

登录后才能评论

评论列表(0条)

    保存