在Postgres中增加字符变化类型的大小而不会丢失数据 [英] Increasing the size of character varying type in postgres without data loss
问题描述
我需要在不丢失数据的情况下增加postgres数据库表中的character changes(60)字段的大小。
I need to increase the size of a character varying(60) field in a postgres database table without data loss.
我有此命令
alter table client_details alter column name set character varying(200);
此命令是否将字段大小从60增加到200而不会丢失数据?
will this command increase the the field size from 60 to 200 without data loss?
推荐答案
引用此文档,不会丢失任何数据,更改列
仅将旧数据转换为新数据,因此字符数据之间的转换应该可以。但是我认为您的语法不正确,请参阅我前面提到的文档。我认为您应该使用以下语法:
Referring to this documentation, there would be no data loss, alter column
only casts old data to new data so a cast between character data should be fine. But I don't think your syntax is correct, see the documentation I mentioned earlier. I think you should be using this syntax :
ALTER [COLUMN]列TYPE类型[
USING expression]
ALTER [ COLUMN ] column TYPE type [ USING expression ]
注意,创建表,填充表并进行测试不是更容易吗?
And as a note, wouldn't it be easier to just create a table, populate it and test :)
这篇关于在Postgres中增加字符变化类型的大小而不会丢失数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!