对10进制16位长的主键的缩短处理 NULL
# 对问题表去除旧有主键,新建自增主键;
ALTER TABLE `question`
CHANGE COLUMN `id` `id16` bigint(20) NULL COMMENT 'id_to_drop' FIRST ,
ADD COLUMN `idnew` bigint NOT NULL AUTO_INCREMENT COMMENT 'id' AFTER `status`,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`idnew`);
# 对答案表新增qidtmp临时字段;
ALTER TABLE answer ADD COLUMN qidtmp bigint NULL AFTER qid; 优化为
ALTER TABLE answer ADD COLUMN qidtmp bigint NOT NULL DEFAULT 0 AFTER qid;
# 连表更新;
UPDATE answer a SET qidtmp = (SELECT idnew FROM question WHERE id16= a.qid);
# 手动检验
# 字段删除;修改名称
借助临时字段的思路
快速给数据库大表添加字段或索引方法 - jiahao1186的专栏 - CSDN博客 https://blog.csdn.net/jiahao1186/article/details/81039613
借助临时表的思路