How To Get a List of Indexes of an Existing Table?
Submitted by: AdministratorIf you want to see the index you have just created for an existing table, you can use the "SHOW INDEX FROM tableName" command to get a list of all indexes in a given table. The tutorial script below shows you a nice example:
<pre>mysql> SHOW INDEX FROM TIP;
+------------+-------------+--------------+-------------+...
| Non_unique | Key_name | Seq_in_index | Column_name |...
+------------+-------------+--------------+-------------+...
| 0 | PRIMARY | 1 | id |...
| 1 | tip_subject | 1 | subject |...
+------------+-------------+--------------+-------------+...</pre>
2 rows in set (0.03 sec)
It's interesting to see that there is a default index for the primary key column.
Submitted by: Administrator
<pre>mysql> SHOW INDEX FROM TIP;
+------------+-------------+--------------+-------------+...
| Non_unique | Key_name | Seq_in_index | Column_name |...
+------------+-------------+--------------+-------------+...
| 0 | PRIMARY | 1 | id |...
| 1 | tip_subject | 1 | subject |...
+------------+-------------+--------------+-------------+...</pre>
2 rows in set (0.03 sec)
It's interesting to see that there is a default index for the primary key column.
Submitted by: Administrator
Read Online MySQL Programming Job Interview Questions And Answers
Top MySQL Programming Questions
☺ | How To Use Regular Expression in Pattern Match Conditions? |
☺ | What Is TIMESTAMP in MySQL? |
☺ | How To Use CASE Expression? |
☺ | How To Delete an Existing Column in a Table? |
☺ | What Is View? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |