Database Reference
In-Depth Information
The results show a new KEY after the list of columns. The key, or index, is called hu-
man_names and is based on the values of the two columns listed in parentheses. Let's
use another SQL statement to see more information about this new index. We'll use the
SHOW INDEX statement like so:
SHOW INDEX FROM birdwatchers.humans
WHERE Key_name = 'human_names' \G
*************************** 1. row ***************************
Table: humans
Non_unique: 1
Key_name: human_names
Seq_in_index: 1
Column_name: name_last
Collation: A
Cardinality: NULL
Sub_part: NULL
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
*************************** 2. row ***************************
Table: humans
Non_unique: 1
Key_name: human_names
Seq_in_index: 2
Column_name: name_first
Collation: A
Cardinality: NULL
Sub_part: NULL
Packed: NULL
Null: YES
Index_type: BTREE
Comment:
This SQL statement shows the components of the human_names index. The results
show two rows with information on the columns that were used to create the index.
There's plenty of information here about this index. It's not important that you understand
what it all means at this point in learning MySQL and MariaDB. What I want you to see
here is that the name of the index is different from the columns upon which it's based.
When there's only one column in the index and the index for it has the same name, it
doesn't mean that they are the samething.
Let's try the EXPLAIN...SELECT again tosee the difference from earlier when we
didn't have the human_names index:
Search WWH ::




Custom Search