mysql 取消索引設定 mysql新增刪除索引

2021-10-17 17:13:10 字數 1111 閱讀 9571

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;

mysq索引類別

索引都是在儲存引擎層面實現的 1.btree索引 使用b tree資料結構建立的索引,索引值都是按順序存放的,儲存引擎不需要再全表掃瞄,取而代之的是從索引的根節點開始掃瞄,根節點存放了子節點的指標,隨著向下層查詢,隨著查詢值和節點值的比較 指標中右節點葉值的上下限 最終找到記錄。btree索引可以選...

mysql設定索引

1.新增primary key 主鍵索引 語法 alter table 表名 add primary key 列名稱 mysql alter table table name add primary key column 2.新增unique 唯一索引 語法 alter table 表名 add u...

mysql聚簇索引設定 Mysql 聚簇索引

整體概述 1.innodb的主索引檔案上 直接存放該行資料,稱為聚簇索引,次索引指向對主鍵的引用 2.myisam中,主索引和次索引,都指向物理行 磁碟位置 哈哈,說了兩句貌似聽不懂的話。一。通俗解釋 我們可以這麼理解 聚簇索引 innodb 索引的葉節點就是資料節點,下邊實打實有資料。非聚簇索引 ...