达梦数据库运维相关查询命令

复制代码
-- 当前死锁
SELECT
    lc.lmode,
    lc.table_id,
    lc.blocked,
    vtw.id AS trx_id,
    vs.sess_id,
    vs.sql_text,
    vs.appname,
    vs.clnt_ip
FROM
    v$lock lc
LEFT JOIN
    v$trxwait vtw ON (lc.trx_id = vtw.id)
LEFT JOIN
    v$trx vt ON (vtw.id = vt.id)
LEFT JOIN
    v$sessions vs ON (vt.sess_id = vs.sess_id)
WHERE
    vs.sql_text IS NOT NULL;

SELECT
    VTW.ID AS TRX_ID,
    VS.SESS_ID,
    VS.SQL_TEXT,
    VS.APPNAME,
    VS.CLNT_IP
FROM
    V$TRXWAIT VTW
LEFT JOIN
    V$TRX VT ON(VTW.ID = VT.ID)
LEFT JOIN
    V$SESSIONS VS ON(VT.SESS_ID = VS.SESS_ID);

SELECT * FROM V$LONG_EXEC_SQLS
where exec_time >= 10000 ;

-- 历史大于10s的sql
SELECT *
FROM v$sql_history
where time_used > 10000000
  and start_time >= current_date
limit 10;

-- 查询系统访问用户是否过多
select count(1)
from (select clnt_ip from v$sessions where create_time > '2024-09-09' group by clnt_ip);

select * from V$CONNECT where STATUS$='ACTIVE';  --查询正在使用的连接

select ip_addr,count(1) from V$CONNECT group by ip_addr;--每个主机开启的连接数

select a.sess_id, b.name, a.sql_text, a.clnt_ip
from v$sessions a,
     V$CONNECT b
where a.sess_id = b.saddr
    and b.ip_addr = '::ffff:172.30.150.40'
order by b.name, b.ip_addr;--每个链接对应的会话


select *
from (select regexp_replace(top_sql_text, '[''][[:print:]]*['']', '') sql1, count(1) cc
      from V$SQL_HISTORY
      group by regexp_replace(top_sql_text, '[''][[:print:]]*['']', ''))
order by cc desc limit 20;--根据sql的调用次数降序排列

-- 干掉会话
sp_close_session(1397145640);

select *
from V$SQL_HISTORY
where time_used > 10000000
order by start_time desc;--查询出执行时间超过3s的sql;
复制代码
-- 事务等待:使用如下sql查询数据库中的事务等待信息,如果为空,则表示当前无事务等待。
-- 死锁事务
select * from v$trxwait;
select b.name, t.* from v$lock t, SYSOBJECTS b where t.BLOCKED = 1   and t.TABLE_ID = b.ID;
相关推荐
LUCIAZZZ42 分钟前
简单的SQL语句的快速复习
java·数据库·sql
马立杰1 小时前
H3CNE-33-BGP
运维·网络·h3cne
云空2 小时前
《DeepSeek 网页/API 性能异常(DeepSeek Web/API Degraded Performance):网络安全日志》
运维·人工智能·web安全·网络安全·开源·网络攻击模型·安全威胁分析
Elastic 中国社区官方博客2 小时前
使用真实 Elasticsearch 进行高级集成测试
大数据·数据库·elasticsearch·搜索引擎·全文检索·jenkins·集成测试
@_@哆啦A梦3 小时前
Redis 基础命令
java·数据库·redis
fajianchen3 小时前
MySQL 索引存储结构
数据库·mysql
没有名字的小羊3 小时前
Cyber Security 101-Build Your Cyber Security Career-Security Principles(安全原则)
运维·网络·安全
想做富婆3 小时前
oracle: 多表查询之联合查询[交集intersect, 并集union,差集minus]
数据库·oracle·联合查询
千夜啊3 小时前
Nginx 运维开发高频面试题详解
运维·nginx·运维开发
存储服务专家StorageExpert4 小时前
答疑解惑:如何监控EMC unity存储系统磁盘重构rebuild进度
运维·unity·存储维护·emc存储