按照documentation,琴弦比由字符改变或VARCHAR指定的时间更长应被截断:PostgreSQL里没有截断超长字符串
If one explicitly casts a value to character varying(n) or character(n), then an over-length value will be truncated to n characters without raising an error. (This too is required by the SQL standard.)
,但我无法得到它的工作。现在文档确实表示,必须“明确”为字符变化赋予一个值,所以也许我错过了这一点。下面是一个简单的测试表:太长值类型字符改变(20)
insert into test1 values
('this is a super long string that we want to see if it is really truncated');
我怎样才能得到这个工作:
create table test1(
tval character varying(20));
在以下失败,错误?
什么文件说长字符串会自动截断?你能引用相关文件或提供链接吗? MySQL做这样的事情(取决于它如何配置),PostgreSQL更明智。 – 2014-12-01 23:58:57