新增主键列
背景:客户几百万数据想要新增一列表做主键
方案:初步客户想新增序列作为主键
但序列为单线程获取,若业务量大会影响业务的在高并发下的性能
讨论后决定创建timestamp与前端生成的hash值当联合主键,hash值主要负责解决历史数据
因当前存在数量多,添加列方案为创建空表结构,再进行添加时间戳列,再次进行数据导入
若不方便进行应用表名替换,还可进行rename操作
create table t1 as select * from t2 where 1=2;
alter table t1 add col0 timestamp primary key;
alter table t1 modify col0 default sysdate;
导出导入数据方案可用create as