• mysql常用sql语句


            mysql常用sql语句

    show variables like '%max_connections%'; //查看数据库的最大连接数;

    SET GLOBAL max_connections=2000;//设置最大连接数,重启后失效,永久生效需要在配置文件中修改。

    show  PROCESSLIST;//连接详细信息

    show status like 'Threads%';//查看连接线程数

    show procedure status;//查看存储过程

    select count(*) as total from table_name;//查看表有多少条数据

    desc table_name; //查看表结构

    show table status where comment='view';//查看视图

    show index from table_name;// 查看索引

    show variables like 'slow_query%';//查看慢查询的日志路径,以及是否开启慢查询。OFF为未开启

    show variables like '%version%';查看数据库的版本信息

    查看正在执行的事务:
    SELECT
        trx_id as '事务ID',
        trx_state as '事务状态',
        trx_requested_lock_id as '事务需要等待的资源',
        trx_wait_started as '事务开始等待时间',
        trx_tables_in_use as '事务使用表',
        trx_tables_locked as '事务拥有锁',
        trx_rows_locked as'事务锁定行',
        trx_rows_modified  as '事务更改行'  
    FROM information_schema.INNODB_TRX;

    查看正在锁的事务:
    SELECT
        lock_id as '锁ID',
        lock_trx_id as '拥有锁的事务ID',
        lock_mode as '锁模式',
        lock_type as '锁类型',
        lock_table as '被锁的表',
        lock_index as '被锁的索引',
        lock_space as '被锁的表空间号',
        lock_page as '被锁的页号',
        lock_rec as '被锁的记录号',
        lock_data as '被锁的数据'
    FROM information_schema.INNODB_LOCKS;

    查看正在等待的事务:
    SELECT
      requesting_trx_id as'请求锁的事务ID',
      requested_lock_id as '请求锁的锁ID',
      blocking_trx_id as '当前拥有锁的事务ID',
      blocking_lock_id as '当前拥有锁的锁ID'
    FROM information_schema.INNODB_LOCK_WAITS;

    学习是一种信仰
  • 相关阅读:
    Mysql数据操作指令
    Mysql列属性
    Mysql表的对应关系
    Mysql中的一些类型
    Mysql笔记
    (三) rest_framework 权限与限流源码梳理
    (二) rest_framework 认证源码流程与配置
    (一) rest_framework 视图入口
    django_celery_beat
    GRPC
  • 原文地址:https://www.cnblogs.com/nickxr/p/10239819.html
Copyright © 2020-2023  润新知