天天看點

pgsql -- 常用表結構修改

修改

字段的字元串

長度

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常用指令