mysql查看某张表、库的大小

本文介绍了如何使用MySQL查询表的大小,展示数据库表的数据,并详细解释了如何查看表的结构,包括字段类型、是否允许空值、键类型等信息,为数据库管理和优化提供了实用的SQL语句。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 |         |
+--------------+----------------------+-----------+------+-----+-------------------+-----------------------------+---------------------------------+---------+
 

 

 

 

转载于:https://www.cnblogs.com/Knight7971/p/9963299.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值