You can ask MySQL to show you table metadata; that is, information about your tables. Metadata includes information such as table names or column or index definitions.
The INFORMATION_SCHEMA database has a TABLES table that contains table metadata. For example, to display information about a particular, use this statement:
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='mytbl';
Information about indexes is available from INFORMATION_SCHEMA in the STATISTICS table.
SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='mytbl';
MySQL also supports a family of SHOW statements that display metadata. Some that pertain to tables are SHOW TABLES and SHOW CREATE TABLE. To determine the tables that a particular database contains, use SHOW TABLES:
SHOW TABLES FROM mydb;
SHOW TABLES FROM mydb LIKE '%tr%';
SHOW CREATE TABLE table_name;
DESCRIBE is another statement that displays table structure metadata:
DESCRIBE table_name;
DESCRIBE table_name is a synonym for SHOW COLUMNS FROM table_name or SHOW FIELDS FROM table_name. These statements are equivalent:
DESCRIBE table_name
SHOW COLUMNS FROM table_name;
SHOW FIELDS FROM table_name;
You can also use SHOW to obtain index information. To find out what indexes a table has, use SHOW CREATE TABLE to display the CREATE TABLE statement that corresponds to the table structure, including its indexes. For more detailed information about the indexes, use SHOW INDEX. For example:
SHOW INDEX FROM table_name;