인덱스나 제약조건 생성시
인덱스명을 지정하여 생성하여도 인덱스 명이 자동으로 생성이 되던데
원래 그런건가요...? (인덱스 명을 지정해도 primary로 생성이 되더라구요ㅠㅠ 제약조건은 테이블명_FK)
아니면 변경하는 설정이 따로 있는건지요...?
글쎄요 mysql 버전이 다르거나 무슨 옵션이 적용되어서 그런건지..
mysql> create index idx_test on test (a); Query OK, 2 rows affected (0.27 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> show index from test; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | test | 1 | idx_test | 1 | a | A | NULL | NULL | NULL | YES | BTREE | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ 1 row in set (0.00 sec) mysql> explain select * from test where a=2; +----+-------------+-------+------+---------------+----------+---------+-------+------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+------+---------------+----------+---------+-------+------+-------------+ | 1 | SIMPLE | test | ref | idx_test | idx_test | 5 | const | 1 | Using where | +----+-------------+-------+------+---------------+----------+---------+-------+------+-------------+ 1 row in set (0.11 sec)
mysql> create index idx_test on test (a);
Query OK, 2 rows affected (0.27 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> show index from test;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
| test | 1 | idx_test | 1 | a | A | NULL | NULL | NULL | YES | BTREE | |
1 row in set (0.00 sec)
mysql> explain select * from test where a=2;
+----+-------------+-------+------+---------------+----------+---------+-------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
| 1 | SIMPLE | test | ref | idx_test | idx_test | 5 | const | 1 | Using where |
1 row in set (0.11 sec)