暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

知识点 | MySQL常用的几条管控语句

原创 杨磊 2021-03-02
419
  1. Mysql数据库大小查看
    select table_schema,round(sum(data_length+index_length)/1024/1024/1024,4) from information_schema.tables group by table_schema;

2.查看正在执行的sql
SELECT * FROM information_schema.PROCESSLIST WHERE info IS NOT NULL;

3.查看innodb内核中的当前活跃(ACTIVE)事务
select * from information_schema.innodb_trx;

4. 查看当前状态产生的innodb锁
select * from information_schema.innodb_locks;

5. 查看当前状态产生的innodb锁等待
select * from information_schema.INNODB_LOCK_WAITS;

6.存储过程的信息都存储在 information_schema 数据库下的 Routines 表中
select name from mysql.proc where db = ‘your_db_name’ and type = ‘PROCEDURE’;

7.存储过程的信息也存放在information_schema.Routines,
举例:查阅名为 showstuscore 的存储过程的状态:
SELECT * FROM information_schema.Routines WHERE ROUTINE_NAME=存储过程名;

8.查询数据库中的存储过程和函数
select name from mysql.proc where db = ‘xx’ and type = ‘PROCEDURE’   //存储过程
select name from mysql.proc where db = ‘xx’ and type = ‘FUNCTION’   //函数
show procedure status; //存储过程
show function status;     //函数

9.查看存储过程或函数的创建代码
show create procedure proc_name;
show create function func_name;

  1. 查看视图
    SELECT * from information_schema.VIEWS   //视图
    SELECT * from information_schema.TABLES   //表

  2. 查看触发器
    SHOW TRIGGERS [FROM db_name] [LIKE expr]
    SELECT * FROM triggers T WHERE trigger_name=”mytrigger” \G

以下为个人公众号,欢迎扫码关注:
image.png

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论