mysql语法存在哪些查询方法,下面编程教程网小编给大家详细介绍一下各种查询方法!
查看库的大小,剩余空间的大小
select table_schema,round((sum(data_length / 1024 / 1024) + sum(index_length / 1024 / 1024)),2)
dbsize,round(sum(DATA_FREE / 1024 / 1024),2) freesize,
round((sum(data_length / 1024 / 1024) + sum(index_length / 1024 / 1024) +
sum(DATA_FREE / 1024 / 1024)),2) spsize from information_schema.tables
where table_schema not in ('mysql','information_schema','performance_schema')
group by table_schema order by freesize desc;
查询正在运行中的事务
select p.id,p.user,p.host,p.db,p.command,p.time,i.trx_state,i.trx_started,p.info
from information_schema.processlist p,information_schema.innodb_trx i
where p.id=i.trx_mysql_thread_id;
查看库中所有表的大小
select table_name,concat(round(sum(DATA_LENGTH/1024/1024),2),'M')
from information_schema.tables where table_schema='t1'
group by table_name;
查看库中有索引的表
select TABLE_SCHEMA,TABLE_NAME,group_concat(INDEX_NAME) from information_schema.STATISTICS where
TABLE_SCHEMA not in ('sys','mysql','information_schema','performance_schema')
group by TABLE_NAME ;
查看库中没有索引的表
select TABLE_SCHEMA,TABLE_NAME from information_schema.tables
where TABLE_NAME not in (select distinct(any_value(TABLE_NAME))
from information_schema.STATISTICS group by INDEX_NAME)
and TABLE_SCHEMA not in ('sys','mysql','information_schema','performance_schema');
以上是编程学习网小编为您介绍的“mysql语法中有哪些查询方法”的全面内容,想了解更多关于 mysql 内容,请继续关注编程基础学习网。
编程基础网
本文标题为:mysql语法中有哪些查询方法
基础教程推荐
猜你喜欢
- PostgreSQL 查看数据库,索引,表,表空间大小的示例代码 2023-12-12
- php+mysql查询优化简单实例 2023-12-12
- 深入了解MySQL锁机制及应用场景 2023-12-30
- MySQL通用查询日志(General Query Log) 2024-01-13
- MySQL是如何保证数据的完整性 2023-12-12
- 使用 SQL 服务器时,”评估期已过期”错误消息(解决方法) 2023-12-03
- Oracle 删除大量表记录操作分析总结 2023-07-23
- MySQL悲观锁与乐观锁的实现方案 2023-08-06
- 关于Redis bigkeys命令会阻塞问题的解决 2023-07-13
- mysql 触发器的使用及注意点 2022-09-12
