mysql添加删除索引
Posted 一沙世界
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql添加删除索引相关的知识,希望对你有一定的参考价值。
mysql> show create table table_test;
+---------------------------------------+---------------------------+
| Table | Create Table |
+---------------------------------------+---------------------------+
| table_test | CREATE TABLE `table_test` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT ‘涓婚敭‘,
`activity_id` varchar(20) NOT NULL COMMENT ‘娲诲姩ID‘,
`store_code` varchar(100) NOT NULL COMMENT ‘娲诲姩鍚嶇О‘,
`generation_date` date DEFAULT NULL COMMENT ‘鐢熸垚鏃ユ湡,鏍煎紡锛歽yyy-MM-dd‘,
`ordercon_num` bigint(20) DEFAULT ‘0‘ COMMENT ‘璁㈠崟杞寲浜烘暟‘,
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT ‘鍒涘缓鏃堕棿‘,
`update_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT ‘鏇存柊鏃堕棿‘,
`delete_flag` varchar(1) DEFAULT ‘1‘ COMMENT ‘鐘舵€?1-鍚敤锛?-鍒犻櫎‘,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_activityid_date` (`activity_id`,`generation_date`) USING BTREE,
KEY `idx_storecode` (`store_code`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=‘搴楅摵缁村害澶╄〃‘ |
+---------------------------------------+---------------------------
乱码正好算加密了~
删除联合主键索引:
ALTER TABLE table_test DROP INDEX `uk_activityid_date`;
添加索引:
ALTER TABLE table_test ADD INDEX `idx_activityid` (`activity_id`) USING BTREE;
以上是关于mysql添加删除索引的主要内容,如果未能解决你的问题,请参考以下文章