MySQL.索引
时间:2021-07-01 10:21:17
帮助过:5人阅读
单字段索引
CREATE INDEX LAST_NAME_INDEX
-> ON EMPLOYEE_TBL (LAST_NAME);
Query OK, 0 rows affected (
0.06 sec)
-- 唯一索引
CREATE UNIQUE INDEX LAST_NAME_UNIQUE_INDEX
-> ON EMPLOYEE_TBL (LAST_NAME);
ERROR 1062 (
23000): Duplicate entry
‘GLASS‘ for key ‘LAST_NAME_UNIQUE_INDEX‘
-- 组合索引
CREATE INDEX ORDER_INDEX
-> ON ORDERS_TBL (CUST_ID, PROD_ID);
Query OK, 0 rows affected (
0.02 sec)
-- 修改索引
ALTER INDEX INDEX_NAME
-- 删除索引
DROP INDEX LAST_NAME_INDEX
-> ON EMPLOYEE_TBL;
Query OK, 0 rows affected (
0.03 sec)
Records: 0 Duplicates:
0 Warnings:
0
DROP INDEX ORDER_INDEX
-> ON ORDERS_TBL;
Query OK, 0 rows affected (
0.04 sec)
Records: 0 Duplicates:
0 Warnings:
0
MySQL.索引
标签: