Wil*_*nes 5 postgresql varchar truncate
我目前有一个包含varchar(10000)列的Postgres 8.4数据库.我想将其更改为varchar(255)并截断任何碰巧太长的数据.我怎样才能做到这一点?
1) 使用子串方法更新列数据以截断它
update t set col = substring(col from 1 for 255)
Run Code Online (Sandbox Code Playgroud)
2)然后改变表列
alter table t alter column col type varchar(255)
Run Code Online (Sandbox Code Playgroud)
文档在这里http://www.postgresql.org/docs/8.4/static/sql-altertable.html
| 归档时间: |
|
| 查看次数: |
3641 次 |
| 最近记录: |