Ben iki alan üzerinde MySQL endeksi tanımlarsanız, nasıl (MySQL komutları kullanarak) birbirine ait olan iki öğrenebilirim.
İşte bir örnek tablo:
mysql> DESCRIBE lansuite_wiki_versions;
+-----------+-----------------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------------------+------+-----+-------------------+-----------------------------+
| versionid | int(11) | NO | PRI | 0 | |
| postid | int(11) | NO | PRI | 0 | |
| date | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| kimliği | mediumint(8) unsigned | NO | MUL | 0 | |
| metin | metin | NO | MUL | NULL | |
| test1 | int(11) | NO | MUL | NULL | |
| test2 | int(11) | NO | | NULL | |
+-----------+-----------------------+------+-----+-------------------+-----------------------------+
7 rows in set (0.00 sec)
Bu tablo üzerinde tanımlanmış dizinleri vardır:
- versionid + ID'si
- kimliği
- test1 + dnm2
- metin
I know this, because I have assigned them and see them in phpmyadmin. But I want to see it in my application as well. So I found this mySQL command:
mysql> SHOW INDEX FROM lansuite_wiki_versions;
+------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| lansuite_wiki_versions | 0 | PRIMARY | 1 | versionid | A | NULL | NULL | NULL | | BTREE | |
| lansuite_wiki_versions | 0 | PRIMARY | 2 | postid | A | 144 | NULL | NULL | | BTREE | |
| lansuite_wiki_versions | 1 | kimliği | 1 | kimliği | A | 4 | NULL | NULL | | BTREE | |
| lansuite_wiki_versions | 1 | test | 1 | test1 | A | 1 | NULL | NULL | | BTREE | |
| lansuite_wiki_versions | 1 | test | 2 | test2 | A | 1 | NULL | NULL | | BTREE | |
| lansuite_wiki_versions | 1 | metin | 1 | metin | NULL | 1 | NULL | NULL | | FULLTEXT | |
+------------------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
6 rows in set (0.00 sec)
But how do I see versionid + ID'siis connected? I can see Seq_in_index counting up. So can I rely on that versionid and postid form a common index, just because they are standing in rows next to each other in this output and the Seq_in_index countin up? Or is there an other command, that shows me which indexes are defined?