当一个表有主键,会有如下语句(local代表是分区表):
alter table TR_GOV_FM_REGINFO_D add constraint PK_TR_GOV_FM_REGINFO_D primary key (FILE_TIME, IDCARD, FM_NUMBER) using index local;
删除主键
alter table TR_GOV_FM_REGINFO_D drop constraint PK_TR_GOV_FM_REGINFO_D ;
然而会留下唯一索引
create unique index PK_TR_GOV_FM_REGINFO_D on TR_GOV_FM_REGINFO_D (FILE_TIME, IDCARD, FM_NUMBER) local;
再删除唯一索引
drop index PK_TR_GOV_FM_REGINFO_D;
至此变删除主键约束了
然后加主键,注意主键字段不能为空,且不能重复。
update TR_GOV_FM_REGINFO_D set data_type='1' where data_type is null ;
alter table TR_GOV_FM_REGINFO_D add constraint PK_TR_GOV_FM_REGINFO_D primary key (FILE_TIME, data_type, IDCARD, FM_NUMBER) using index local;