美文网首页
mysql常用查询信息

mysql常用查询信息

作者: su酥饼 | 来源:发表于2024-07-08 10:37 被阅读0次
  1. 统计当前实例中业务相关的库和表的信息(排除掉mysql sys information_schema
    performance_schema)
    库名 表个数 表名列表
mysql> select table_schema,group_concat(table_name),count(*) from
information_schema.tables where table_schema not in
('sys','mysql','information_schema','performance_schema') group by table_schema;
  1. 统计当前实例每个数据库的数据总量(排除掉mysql sys information_schema
    performance_schema)
select table_schema,sum(table_rows * avg_row_length + index_length)/1024/1024 as
total_mb
from information_schema.tables
where table_schema not in
('sys','mysql','information_schema','performance_schema')
group by table_schema;
  1. 统计当前实例非innodb的表(排除掉mysql sys information_schema performance_schema)
select table_schema,table_name ,engine
from information_schema.tables
where table_schema not in
('sys','mysql','information_schema','performance_schema') and engine <>
'INNODB';
alter table world.aaaaa engine=innodb;
  1. 查询有碎片的表信息
select table_schema,table_name ,data_free
from information_schema.tables
where table_schema not in
('sys','mysql','information_schema','performance_schema')
and data_free >0;
  1. 查询出本地外的连接信息
 select * from information_schema.processlist where host !='locakhost';
  1. 拼接SQL
    a. 查询当前系统中所有非INNODB的表。
select table_schema,table_name ,engine
from information_schema.tables
where table_schema not in
('sys','mysql','information_schema','performance_schema') and engine <>
'INNODB';

b. 将这些非INNODB的表替换为INNODB
8.3.4 TRIGGERS、views、ROUTINES、EVENTS应用
8.3.5 columns
8.3.6 processlist应用

mysql> select concat("alter table ",table_schema,".",table_name,"
engine=innodb;") from information_schema.tables where table_schema not
in ('sys','mysql','information_schema','performance_schema') and engine <>
'INNODB' into outfile '/tmp/alter.sql';
source /tmp/alter.sql

相关文章

  • Mysql常用语句

    1.查询数据库所有表信息: 2.查询数据库所有表字段结构: 3.查询数据库所有视图定义: 4.mysql常用函数:

  • Elastic检索技巧总结

    常用的检索类型 在mysql中,我们常用的查询 可能就是 精准查询 模糊查询 范围查询 等等,那么在es中,有哪...

  • mysql调优及常用命令

    mysql常用命令 慢查询日志 mysqlddumpslow(查看慢查询日志) mysql5.7(虚拟列) mys...

  • MySQL之binlog日志、undo日志、redo日志

    一、MySQL常用的几种日志 MySQL主要包含以下几种日志: 错误日志 查询日志 慢查询日志 事务日志 [und...

  • mysql自我小结

    MySql索引 存储引擎 查询mysql支持的引擎:show engines 常用引擎: MyISAM,InnoD...

  • InnoDB引擎中查询锁的信息

    InnoDB中查询锁的信息主要基于三个查询语句 MySQL 5.7 MySQL 8.0 本文将分别基于 MySQL...

  • MySQL常用查询

    其实在工作中用SQL挺多的,不过一般都是单表查询,平时出报表会使用到JOIN函数,记录一些常用的函数。 Excep...

  • MySql常用查询

    要查询数据库 "mammothcode" 下所有表名以及表注释 要查询表字段的注释 一次性查询数据库 "mammo...

  • mysql 常用查询

    题目来源:https://blog.csdn.net/mrbcy/article/details/68965271...

  • Mysql常用功能

    MYSQL常用及存储过程一、常用查询语句1)LIKE的灵活运用 2)分组查询 实例:查询骑手商城的商品中定价大于1...

网友评论

      本文标题:mysql常用查询信息

      本文链接:https://www.haomeiwen.com/subject/vcnocjtx.html