如何找到 MySQL 表中當前的大小(記憶體中)?
要得到某個表的當前大小,使用以下命令,它會顯示關於表的詳細資訊,包括大小 −
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) -> ); Query OK, 0 rows affected (0.75 sec)
使用 insert 命令在表中插入一些記錄 −
mysql> insert into DemoTable(CustomerName,CustomerAge,CustomerCountryName) values('John',24,'US');
Query OK, 1 row affected (0.23 sec)
mysql> insert into DemoTable(CustomerName,CustomerAge,CustomerCountryName) values('Carol',22,'UK');
Query OK, 1 row affected (0.14 sec)使用 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)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP