# 生成删除索引的SQL |
测试结果| concat(
'alter table `',
table_schema,
'`.`',
table_name,
'` add ',
case when NON_UNIQUE=0 then 'UNIQUE'
else '' end,
' index `',
index_name,
'` (',
GROUP_CONCAT(concat('`',column_name,'`')),
');'
) |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| alter table `test01`.`t1` add UNIQUE index `new2` (`new2`); |
| alter table `test01`.`t1` add index `idx_h` (`hana`); |
| alter table `test01`.`t1` add index `idx_s` (`stock`); |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
对比索引
# 检查主键是否一致 |