1.对已存在的表添加列 和注释
alter table tableName add COLUMN columnName varchar(50); comment on column tableName.columnName is '注释';
2.对已存在的列设置主键
ALTER TABLE tableName ADD CONSTRAINT xxx_xxx_primary_pk PRIMARY KEY (列);
3.创建自增
DROP SEQUENCE IF EXISTS {table_name}_nid_seq; CREATE SEQUENCE {table_name}_nid_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1; alter table trans.{table_name} alter column nid set default nextval('{table_name}_nid_seq');