对有数据的表,追加主键
DB的主键追加
第一种
先把表重命名
alter table 旧表名 rename to “新表名”
alter table “新表名” drop constraint 主键
创建旧表名的表
create table public.表名(
列名 character varying(10) not null
,列名
略
,primary key (列名,列名)
);
COMMENT ON TABLE public.表名 IS '汉字表名';
COMMENT ON COLUMN public.表名.列名 IS '汉字列名'
数据移行
insert into 旧表名 (列名,略
)select 列名
,略
from 新表名
删除 新表
drop table if exists “新表名” cascade;
第二种方法
删除主键
alter table 表名 drop constraint 主键名;
追加主键
alter table 表名 add constraint 主键名 primary key(列名,列名);

浙公网安备 33010602011771号