文本数据类型和字符变化(varchar)数据类型之间有什么区别?
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)。
原文链接:https://www.f2er.com/postgresql/194090.html检查这篇文章从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得出结论,其中之一通常是长度限制的最佳选择。