要获取表的当前大小,请使用以下内容来显示有关表的详细信息,包括大小-
show table status like ‘yourTableName’\G
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> CustomerName varchar(20), -> CustomerAge int, -> CustomerCountryName varchar(20) -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable(CustomerName,CustomerAge,CustomerCountryName) values('John',24,'US'); mysql> insert into DemoTable(CustomerName,CustomerAge,CustomerCountryName) values('Carol',22,'UK');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+----+--------------+-------------+---------------------+ | Id | CustomerName | CustomerAge | CustomerCountryName | +----+--------------+-------------+---------------------+ | 1 | John | 24 | US | | 2 | Carol | 22 | UK | +----+--------------+-------------+---------------------+ 2 rows in set (0.00 sec)
这是查询以查找表的当前大小(在内存中)-
mysql> show table status like 'DemoTable'\G
输出结果
*************************** 1. row *************************** Name: DemoTable Engine: InnoDB Version: 10 Row_format: Dynamic Rows: 0 Avg_row_length: 0 Data_length: 16384 Max_data_length: 0 Index_length: 0 Data_free: 0 Auto_increment: NULL Create_time: 2019-06-10 16:35:55 Update_time: NULL Check_time: NULL Collation: utf8_unicode_ci Checksum: NULL Create_options: Comment: 1 row in set (0.01 sec)