MySQL/SHOW
来自康健生活
< MySQL
标题文字
数据库
mysql>
SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| nocodb |
| performance_schema |
| qnpm-local |
| test |
+--------------------+
6 rows in set (0.01 sec)
表结构
mysql>
SHOW CREATE TABLE user;
+-------+-----------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-----------------------------------------------------------------------------------------------------+
| user | CREATE TABLE `user` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=latin1 |
+-------+-----------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
表状态
mysql>
SHOW TABLE STATUS WHERE Name = 'user';
+------+--------+---------+------------+------+----------------+-------------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length |
+------+--------+---------+------------+------+----------------+-------------+
| user | InnoDB | 10 | Compact | 12 | 1365 | 16384 |
+------+--------+---------+------------+------+----------------+-------------+
+-----------------+--------------+-----------+----------------+---------------------+
| Max_data_length | Index_length | Data_free | Auto_increment | Create_time |
+-----------------+--------------+-----------+----------------+---------------------+
| 0 | 0 | 0 | 16 | 2022-01-27 17:12:54 |
+-----------------+--------------+-----------+----------------+---------------------+
+-------------+------------+-------------------+----------+----------------+---------+
| Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+-------------+------------+-------------------+----------+----------------+---------+
| NULL | NULL | latin1_swedish_ci | NULL | | |
+-------------+------------+-------------------+----------+----------------+---------+
1 row in set (0.01 sec)
information_schema
mysql>
SELECT *
FROM information_schema.tables
WHERE table_name = 'user';
+---------------+--------------+------------+------------+--------+---------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION |
+---------------+--------------+------------+------------+--------+---------+
| def | mysql | user | BASE TABLE | MyISAM | 10 |
| def | qnpm-local | user | BASE TABLE | InnoDB | 10 |
| def | test | user | BASE TABLE | InnoDB | 10 |
+---------------+--------------+------------+------------+--------+---------+
+------------+------------+----------------+-------------+-----------------+--------------+
| ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH |
+------------+------------+----------------+-------------+-----------------+--------------+
| Dynamic | 6 | 88 | 528 | 281474976710655 | 2048 |
| Compact | 0 | 0 | 16384 | 0 | 32768 |
| Compact | 12 | 1365 | 16384 | 0 | 0 |
+------------+------------+----------------+-------------+-----------------+--------------+
+-----------+----------------+---------------------+---------------------+------------+
| DATA_FREE | AUTO_INCREMENT | CREATE_TIME | UPDATE_TIME | CHECK_TIME |
+-----------+----------------+---------------------+---------------------+------------+
| 0 | NULL | 2021-08-12 15:48:03 | 2021-08-12 15:59:48 | NULL |
| 10485760 | 2 | 2021-08-12 16:00:39 | NULL | NULL |
| 0 | 16 | 2022-01-27 17:12:54 | NULL | NULL |
+-----------+----------------+---------------------+---------------------+------------+
+-------------------+----------+----------------+-----------------------------+
| TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+-------------------+----------+----------------+-----------------------------+
| utf8_bin | NULL | | Users and global privileges |
| utf8_general_ci | NULL | | user base info |
| latin1_swedish_ci | NULL | | |
+-------------------+----------+----------------+-----------------------------+
3 rows in set (0.00 sec)
No categories