인덱스 표시, 인덱스 표시 및 키 표시 간에는 차이가 없습니다. 비슷한 의미를 가지고 있습니다.
먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable1549 -> ( -> EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> EmployeeName varchar(20) -> ); Query OK, 0 rows affected (0.82 sec)
다음은 인덱스를 생성하는 쿼리입니다 -
mysql> create index name_index1 on DemoTable1549(EmployeeName); Query OK, 0 rows affected (0.41 sec) Records: 0 Duplicates: 0 Warnings: 0
다음은 SHOW INDEX −
에 대한 쿼리입니다.mysql> show index from DemoTable1549;
이것은 다음과 같은 출력을 생성합니다 -
+---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | demotable1549 | 0 | PRIMARY | 1 | EmployeeId | A | 0 | NULL | NULL | | BTREE | | | YES | | demotable1549 | 1 | name_index1 | 1 | EmployeeName | A | 0 | NULL | NULL | YES | BTREE | | | YES | +---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ 2 rows in set (0.17 sec)
다음은 SHOW INDEXES −
에 대한 쿼리입니다.mysql> show index from DemoTable1549;
이것은 다음과 같은 출력을 생성합니다 -
+---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | demotable1549 | 0 | PRIMARY | 1 | EmployeeId | A | 0 | NULL | NULL | | BTREE | | | YES | | demotable1549 | 1 | name_index1 | 1 | EmployeeName | A | 0 | NULL | NULL | YES | BTREE | | | YES | +---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ 2 rows in set (0.00 sec)
다음은 SHOW KEYS −
를 구현하는 쿼리입니다.mysql> show keys from DemoTable1549;
이것은 다음과 같은 출력을 생성합니다 -
+---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | +---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ | demotable1549 | 0 | PRIMARY | 1 | EmployeeId | A | 0 | NULL | NULL | | BTREE | | | YES | | demotable1549 | 1 | name_index1 | 1 | EmployeeName | A | 0 | NULL | NULL | YES | BTREE | | | YES | +---------------+------------+-------------+--------------+--------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+ 2 rows in set (0.00 sec)