mysql查看某張表、庫的大小


1、查詢某張表的大小

mysql >  select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from information_schema.tables where table_schema='test' AND table_name='t9'; 

2、查看某個數據庫表的數據

[root@tst-yangsq2-2 ~]# mysqlshow -uroot -p --count test
Enter password: 
Database: test
+--------+----------+------------+
| Tables | Columns  | Total Rows |
+--------+----------+------------+
| t1     |        1 |          2 |
| t2     |        1 |          2 |
| t3     |        2 |          1 |
| t4     |        1 |          6 |
| t5     |        1 |          1 |
| t6     |        1 |         14 |
| t7     |        1 |          0 |
| t8     |        1 |         12 |
| t9     |        7 |      48147 |
+--------+----------+------------+

3、查詢某個數據庫某張表的數據 #類似於desc

[root@tst-yangsq2-2 ~]# mysqlshow -uroot -p --count test t9
Enter password: 
Database: test  Table: t9  Rows: 48147
+--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
| Field        | Type                 | Collation | Null | Key | Default           | Extra                       | Privileges                      | Comment |
+--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
| payment_id   | smallint(5) unsigned |           | NO   |     |                   |                             | select,insert,update,references |         |
| customer_id  | smallint(5) unsigned |           | NO   | MUL |                   |                             | select,insert,update,references |         |
| staff_id     | tinyint(3) unsigned  |           | NO   | MUL |                   |                             | select,insert,update,references |         |
| rental_id    | int(11)              |           | YES  | MUL |                   |                             | select,insert,update,references |         |
| amount       | decimal(5,2)         |           | NO   |     |                   |                             | select,insert,update,references |         |
| payment_date | datetime             |           | NO   |     |                   |                             | select,insert,update,references |         |
| last_update  | timestamp            |           | YES  |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP | select,insert,update,references |         |
+--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM