The SHOW TABLE STATUS command provides a high-level overview and physical statistics for all tables in a database. While commands like DESCRIBE focus on column definitions, SHOW TABLE STATUS focuses on how the table is stored and how much space it uses.
Here are the key pieces of information it provides:
- Storage Engine: Shows which engine the table uses (e.g.,
InnoDB), which determines features like transaction support and foreign keys. - Row Counts (
Rows): Gives an estimate of how many rows are currently in the table. - Physical Size (
Data_length&Index_length):Data_length: How much disk space the actual data occupies.Index_length: how much space the indexes occupy.
- Row Format: Tells you if the rows are
Fixed,Dynamic, orCompressed. - Average Row Length: Shows the average size (in bytes) of a single record.
- Auto-increment Value: If your table has an
AUTO_INCREMENTcolumn, it shows what the next assigned ID will be. - Timestamps: Shows when the table was
Create_time,Update_time, and last checked.
When should you use it?
- Performance Tuning: To check if your indexes are taking up more space than your data.
- Capacity Planning: To see how fast your database is growing and how much disk space you have left.
- Debugging: To quickly check the current engine or the next available auto-increment ID.
Pro-tip: The output of this command can be quite wide in the terminal. If you want to make it more readable, you can terminate the command with \G instead of ;:
SHOW TABLE STATUS FROM store\G
This will display the information in a vertical list format