在PostgreSQL中有一个表的字段为name varchar(6),我想把它更改为name varchar(8),要怎么更改?

来源:百度知道 编辑:UC知道 时间:2024/06/25 09:37:25
我找了很多资料,有一个语法是这样的“alter table table50 alter column name varchar(8)”,但是我试过了,不行!请各位朋友指教一下。
alter table table50 alter column name type varchar(8) ,用这个也不行,提示在type附近有错误

您的PostgreSQL版本是多少?
8.0以下的时候,alter column name type是不起作用的。
有个苯方法。
把表dump下来,在dump文件中对name的type进行修改。然后在create table之前,加上drop table 。重新导入到数据库中。
应该就可以了。

用这个试试
alter table table50 alter column name type varchar(8)