修改
字段的字符串 长度
修改
长度
alter table user alter column email type character varying(150);
删除
不为空的 约束
删除
约束
alter table user alter column age drop not null;
设置 默认值
默认值
alter table user alter column age set default 10;
字段名 重命名
重命名
alter table user rename name to username;
comment on column user.username is ‘用户名’;
添加
字段
添加
alter table user add column email character varying(25);
comment on column user.email is ‘邮箱’;
alter table user add column age integer not null default 10;
comment on column user.age is ‘年龄,默认10岁’;
删除
字段
删除
alter table user drop column email;
相关参考文章
pgsql常用命令