用SQL命令檢視Mysql資料庫大小
用SQL命令檢視Mysql資料庫大小
除了可以直接進入後臺檢視資料檔案大小,可以用SQL命令檢視Mysql資料庫大小
1、進入information_schema 資料庫(存放其他的資料庫的資訊的資料庫)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cacti |
| centreon |
| centreon_status |
| centreon_storage |
| dumpfile |
| mysql |
| syslog |
| test |
+--------------------+
9 rows in set (0.00 sec)
mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
mysql>
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema |
+---------------------------------------+
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
| COLUMN_PRIVILEGES |
| ENGINES |
| EVENTS |
| FILES |
| GLOBAL_STATUS |
| GLOBAL_VARIABLES |
| KEY_COLUMN_USAGE |
| PARTITIONS |
| PLUGINS |
| PROCESSLIST |
| PROFILING |
| REFERENTIAL_CONSTRAINTS |
| ROUTINES |
| SCHEMATA |
| SCHEMA_PRIVILEGES |
| SESSION_STATUS |
| SESSION_VARIABLES |
| STATISTICS |
| TABLES |
| TABLE_CONSTRAINTS |
| TABLE_PRIVILEGES |
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
+---------------------------------------+
28 rows in set (0.00 sec)
2、查詢所有資料的大小:
mysql> select concat(round(sum(data_length/1024/1024/1024),2),'GB') as data from tables;
+----------+
| data |
+----------+
| 110.86GB |
+----------+
1 row in set (1.25 sec)
3、檢視指定資料庫的大小:
mysql> select concat(round(sum(data_length/1024/1024/1024),2),'GB') as data from tables where table_schema='centreon_status';
+--------+
| data |
+--------+
| 4.12GB |
+--------+
1 row in set (0.56 sec)
4、檢視指定資料庫的某個表的大小
比如檢視資料庫home中 members 表的大小
mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='centreon_status' and table_name='nagios_hosts';
+--------+
| data |
+--------+
| 0.31MB |
+--------+
1 row in set (0.00 sec)
mysql>
除了可以直接進入後臺檢視資料檔案大小,可以用SQL命令檢視Mysql資料庫大小
1、進入information_schema 資料庫(存放其他的資料庫的資訊的資料庫)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cacti |
| centreon |
| centreon_status |
| centreon_storage |
| dumpfile |
| mysql |
| syslog |
| test |
+--------------------+
9 rows in set (0.00 sec)
mysql> use information_schema;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql>
mysql>
mysql> show tables;
+---------------------------------------+
| Tables_in_information_schema |
+---------------------------------------+
| CHARACTER_SETS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS |
| COLUMN_PRIVILEGES |
| ENGINES |
| EVENTS |
| FILES |
| GLOBAL_STATUS |
| GLOBAL_VARIABLES |
| KEY_COLUMN_USAGE |
| PARTITIONS |
| PLUGINS |
| PROCESSLIST |
| PROFILING |
| REFERENTIAL_CONSTRAINTS |
| ROUTINES |
| SCHEMATA |
| SCHEMA_PRIVILEGES |
| SESSION_STATUS |
| SESSION_VARIABLES |
| STATISTICS |
| TABLES |
| TABLE_CONSTRAINTS |
| TABLE_PRIVILEGES |
| TRIGGERS |
| USER_PRIVILEGES |
| VIEWS |
+---------------------------------------+
28 rows in set (0.00 sec)
2、查詢所有資料的大小:
mysql> select concat(round(sum(data_length/1024/1024/1024),2),'GB') as data from tables;
+----------+
| data |
+----------+
| 110.86GB |
+----------+
1 row in set (1.25 sec)
3、檢視指定資料庫的大小:
mysql> select concat(round(sum(data_length/1024/1024/1024),2),'GB') as data from tables where table_schema='centreon_status';
+--------+
| data |
+--------+
| 4.12GB |
+--------+
1 row in set (0.56 sec)
4、檢視指定資料庫的某個表的大小
比如檢視資料庫home中 members 表的大小
mysql> select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='centreon_status' and table_name='nagios_hosts';
+--------+
| data |
+--------+
| 0.31MB |
+--------+
1 row in set (0.00 sec)
mysql>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2135954/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL命令檢視資料庫和表容量大小MySql資料庫
- Linux檢視MYSQL資料庫容量大小命令LinuxMySql資料庫
- 檢視oracle資料庫真實大小Oracle資料庫
- SQL Server 檢視錶佔用空間大小SQLServer
- mysql binlog檢視指定資料庫MySql資料庫
- 1.4 資料庫和常用SQL語句(正文)——MySQL資料庫命令和SQL語句資料庫MySql
- MySQL檢視資料庫效能常用命令和實戰教學MySql資料庫
- SQL Server統計資料庫中表大小SQLServer資料庫
- 檢視SQL Server資料庫修改了哪些內容SQLServer資料庫
- 資料庫檢視資料庫
- 資料庫-檢視資料庫
- 查詢MySQL資料庫,MySQL表的大小MySql資料庫
- SQL Server資料庫巡檢SQLServer資料庫
- MySQL資料庫健康檢查--MySQL巡檢MySql資料庫
- Mysql資料庫操作命令MySql資料庫
- Mysql 常用資料庫命令MySql資料庫
- 達夢資料庫SQL執行計劃檢視方法資料庫SQL
- oracle資料庫檢視鎖表的sql語句整理Oracle資料庫SQL
- 如何在Windows下利用Apche檢視MySQL資料庫?WindowsMySql資料庫
- thinkphp6 使用自定義命令,生成資料庫檢視PHP資料庫
- MySQL資料庫之mysql5.7基礎 檢視一個資料庫中的所有表MySql資料庫
- MYSQL資料庫------SQL優化MySql資料庫優化
- sql大資料 基礎(檢視)SQL大資料
- Linux技巧--檢視檔案及資料夾佔用空間大小Linux
- SQL Server資料庫檢視一個資料表各列的註釋SQLServer資料庫
- 【SQLServer】如何檢視某個資料庫中,每個table的資料量大小SQLServer資料庫
- 2.12 資料庫資料字典檢視資料庫
- 資料庫篇:mysql事務原理之MVCC檢視+鎖資料庫MySqlMVC
- SQL Server檢視所有表大小,所佔空間SQLServer
- mysql資料庫中decimal資料型別比較大小MySql資料庫Decimal資料型別
- MSSQL資料庫健康檢查--SQL Server巡檢SQL資料庫Server
- 達夢dimp備份恢復資料庫remap以及檢視錶大小等資料庫REM
- 資料庫的物化檢視資料庫
- openGausspostgreSQL資料庫效能檢視SQL資料庫
- 資料庫檢視的作用資料庫
- 資料庫檢視的使用資料庫
- MySQL 資料庫與 SQL 優化MySql資料庫優化
- 【資料庫學習】資料庫平臺:mysql,sql server資料庫MySqlServer
- 檢視資料庫佔用磁碟空間的方法資料庫