postgresql Postgres:将 varchar 转换为文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2813049/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgres: Convert varchar to text
提问by William Jones
I screwed up and created a column as a varchar(255) where that is no longer sufficient. I've read that varchar has no performance benefits over text on Postgres, and so would like to convert the varchar to a text column in a safe way that preserves the data.
我搞砸了并创建了一个列作为 varchar(255) 不再足够。我已经读过 varchar 与 Postgres 上的文本相比没有性能优势,因此希望以一种安全的方式将 varchar 转换为文本列以保留数据。
What's the best way for me to do this?
我这样做的最佳方法是什么?
回答by rfusca
ALTER TABLE table1 ALTER COLUMN column1 TYPE text;