MySQL/SHOW

来自康健生活
Kangkk​(留言 | 贡献)2022年2月7日 (一) 09:44的版本 (→表状态)

标题文字

数据库

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 table_name, AUTO_INCREMENT
FROM information_schema.tables
WHERE table_name = 'user';
+------------+----------------+
| table_name | AUTO_INCREMENT |
+------------+----------------+
| user       |           NULL |
| user       |              2 |
| user       |             16 |
+------------+----------------+
3 rows in set (0.02 sec)