本文介绍MySQL查看数据库表容量大小的命令语句,提供完整查询语句及实例,方便大家学习使用. 1.查看所有数据库容量大小 select table_schema as '数据库', sum(table_rows) as '记录数', , )) as '数据容量(MB)', , )) as '索引容量(MB)' from information_schema.tables group by table_schema order by sum(data_length) desc, sum(index…
1:show databases; 查看所有的数据库,等同于select schema_name from information_schema.schemata\G.\G 替换;,以纵向报表的形式输出结果,有利于阅读. 2. status 查看mysql数据库的运行状态 3. use 命令选择数据库 例如 use information_schema,当使用此命令后 select schema_name from information_schema.schemata\G,可以为 select…
查看数据库表基本信息. select * from information_schema.TABLES where information_schema.TABLES.TABLE_SCHEMA = '数据库名' and information_schema.TABLES.TABLE_NAME = '表名'; 查看mysql数据库大小 SELECT sum(DATA_LENGTH)+sum(INDEX_LENGTH) FROM information_schema.TABLES where TAB…
有时候在我们开发的过程中并不一定记得数据库的安装路径.比如要查看mysql 数据库的安装目录在哪里:我们可以通过mysql命令查看mysql的安装路径: # 以下两个sql任意一个可查询 select @@basedir as basePath from dual ; show variables like '%basedir%'; 上面可以看到基础的安装路径,查看数据库data的路径怎么看,很简单,把上面的参数变量换成datadir即可: # 以下查询任意一个均可 select @@datad…
使用show status可以查看数据库性能的参数,基本语法:show status like 'value'; 例如: show status like 'Connections';/*连接mysql服务器的次数*/ show status like 'Uptime';/*mysql服务器的上线时间*/ show status like 'slow_queries';/*慢查询的次数*/ show status like 'com_select';/*查询操作的次数*/ show status…
1.查看数据库表数量SELECT count(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='dbname'; select count(*) tables ,table_schema from information_schema.tables where table_schema='work_ad' group by table_schema;…
要想知道每个数据库的大小的话,步骤如下: 1.进入information_schema 数据库(存放了数据库的信息) use information_schema; 2.查询所有数据库的大小: select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables; 3.查看指定数据库的大小: 比如查看数据库home的大小 select concat(round(sum(data_length/1024/1024),…
要想知道每个数据库的大小的话,步骤如下: 1.进入information_schema 数据库(存放了其他的数据库的信息) use information_schema; 2.查询所有数据的大小: select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables; 3.查看指定数据库的大小: 比如查看数据库home的大小 select concat(round(sum(data_length/1024/1024…
静态查看: SHOW PROCESSLIST; SHOW FULL PROCESSLIST; SHOW VARIABLES LIKE '%max_connections%'; SHOW STATUS LIKE '%Connection%'; 实时查看: mysql> show status like 'Threads%'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ |…
mysql> show global status; 可以列出MySQL服务器运行各种状态值,另外,查询MySQL服务器配置信息语句: mysql> show variables; 一.慢查询 mysql> show variables like '%slow%'; +------------------+-------+ | Variable_name | Value | +------------------+-------+ | log_slow_queries | ON…
use information_schema; SELECT DISTINCT t.table_name, t.engine '表引擎', t.table_rowsFROM TABLES tWHERE 1 = 1AND t.table_schema = 'mysql_database_name'-- 自己数据库的名字 AND t. ENGINE IS NOT NULLORDER BY t.table_name,t.table_rows ; SELECTt.TABLE_SCHEMA '数据库',t…
.查询所有数据库占用磁盘空间大小 select TABLE_SCHEMA, concat(,),' MB') as data_size, concat(,),'MB') as index_size from information_schema.tables group by TABLE_SCHEMA ORDER BY data_size desc; .查询单个库中所有表磁盘占用大小 select TABLE_NAME, concat(,),' MB') as data_size, concat…
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),'MB') as data_size, concat(truncate(index_length/1024/1024,2),'MB') as index_size from information_schema.tables where TABLE_SCHEMA = '数据库名称' group by TABLE_NAME order by data_length desc;…
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM information_schema.tables WHERE TABLE_SCHEMA='price_clouds' AND TABLE_NAME='t_match_task_content';…
查询某个表所占用的磁盘空间大小: SELECT CONCAT(ROUND(SUM(data_length/1024/1024),2),'MB') AS data_length_MB, CONCAT(ROUND(SUM(index_length/1024/1024),2),'MB') AS index_length_MB FROM `information_schema`.tables WHERE table_schema='db_name' AND table_name = 'table_nam…
SELECT CONCAT(TRUNCATE(SUM(data_length)//,),'MB') AS data_size, CONCAT(TRUNCATE(SUM(max_data_length)//,),'MB') AS max_data_size, CONCAT(TRUNCATE(SUM(data_free)//,),'MB') AS data_free, CONCAT(TRUNCATE(SUM(index_length)//,),'MB') AS index_size, TABLE_S…
每个mysql都有一个库information_schema,里面有一张表TABLES存储了所有数据库表的信息,因此,可以从这张表中查看数据库大小和表大小 查询数据库大小 ,),'GB') as data from information_schema.tables where table_schema='esb'; 查询数据库中表大小 ,),'GB') as data from information_schema.tables where table_schema='esb' and tab…
Mysql 查看连接数,状态 最大并发数(赞) -- show variables like '%max_connections%'; 查看最大连接数 set global max_connections=1000 重新设置 mysql> show status like 'Threads%'; +-------------------+-------+| Variable_name | Value |+-------------------+-------+| Thread…