MySQL - SHOW TABLE STATUS Statement

The CREATE TABLE statement is used to create tables in MYSQL database. Here, you need to specify the name of the table and, definition (name and datatype) of each column.
The SHOW TABLE STATUS Statement of MySQL provides information about the non-TEMPORARY tables in a database.
Following is the syntax of the SHOW TABLES Statement −
SHOW TABLE STATUS
   [{FROM | IN} db_name]
   [LIKE 'pattern' | WHERE expr]

Assume we have created 4 tables in the current database using the CREATE statement as shown below −
mysql> CREATE TABLE TestTable1(value VARCHAR(10));
Query OK, 0 rows affected (2.88 sec)

mysql> CREATE TABLE TestTable2(value VARCHAR(10));
Query OK, 0 rows affected (0.74 sec)

mysql> CREATE TABLE TestTable3(value VARCHAR(10));
Query OK, 0 rows affected (0.81 sec)

mysql> CREATE TABLE TestTable4(value VARCHAR(10));
Query OK, 0 rows affected (1.26 sec)
Following statement displays the information about the non-temporary trebles in the current database −
mysql> SHOW TABLE STATUS;
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| Name       | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation          | Checksum | Create_options | Comment |
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| testtable1 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:04:03 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| testtable2 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:04:08 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| testtable3 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:04:15 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| testtable4 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:04:21 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
+------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
4 rows in set (0.22 sec)
You can retrieve information about the non-TEMPORARY tables from a specific database using the FROM clause.
Assume we have created a database named demo using the CREATE DATABASE statement −
mysql> CREATE DATABASE demo;
Query OK, 1 row affected (0.18 sec)
Now, let us create tables in it, using the CREATE TABLE statement −
mysql> CREATE TABLE demo.myTable1 (data INT);
Query OK, 0 rows affected (0.55 sec)

mysql> CREATE TABLE demo.myTable2 (data INT);
Query OK, 0 rows affected (1.54 sec)

mysql> CREATE TABLE demo.myTable3 (data INT);
Query OK, 0 rows affected (1.18 sec)

mysql> CREATE TABLE demo.myTable4 (data INT);
Query OK, 0 rows affected (0.86 sec)
Following query lists out the information about tables in the database "demo" −
mysql> SHOW TABLE STATUS FROM demo;
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| Name     | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation          | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| mytable1 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:09:34 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         | 
| mytable2 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:09:47 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable3 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:10:00 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable4 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:10:12 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
4 rows in set (0.20 sec)
You can also use the IN clause instead of FROM as −
mysql> SHOW TABLE STATUS IN demo;
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| Name     | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation          | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| mytable1 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:09:34 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable2 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:09:47 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable3 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:10:00 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable4 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:10:12 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
4 rows in set (0.00 sec)
Using the LIKE clause, you can specify a pattern to retrieve information about specific tables. Following query retrieves description about the tables with name starting with "my".
mysql> use demo;
Database changed
mysql> SHOW TABLE STATUS LIKE 'my%';
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| Name     | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation          | Checksum | Create_options | Comment |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
| mytable1 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:09:34 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable2 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:09:47 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable3 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:10:00 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
| mytable4 | InnoDB | 10      | Dynamic    | 0    | 0              | 16384       | 0               | 0            | 0         | NULL           | 2021-05-13 20:10:12 | NULL        | NULL       | utf8mb4_0900_ai_ci | NULL     |                |         |
+----------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+--------------------+----------+----------------+---------+
4 rows in set (0.00 sec)

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    6 Lectures 
     3.5 hours 

 DATAhill Solutions Srinivas Reddy

    60 Lectures 
     10 hours 

 Vijay Kumar Parvatha Reddy

    10 Lectures 
     1 hours 

 Harshit Srivastava

    25 Lectures 
     4 hours 

 Trevoir Williams
 Print
 Add Notes
 Bookmark this page