知识大全 数据库管理员日常工作中必备的sql列表[1]
Posted 数据库
篇首语:白日放歌须纵酒,青春作伴好还乡。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 数据库管理员日常工作中必备的sql列表[1]相关的知识,希望对你有一定的参考价值。
数据库管理员日常工作中必备的sql列表
监控索引是否使用
alter index &index_name monitoring usage; alter index &index_name nomonitoring usage; select * from v$object_usage where index_name = &index_name;
求数据文件的I/O分布
select df name phyrds phywrts phyblkrd phyblkwrt singleblkrds readtim writetim from v$filestat fs v$dbfile df where fs file#=df file# order by df name;
求某个隐藏参数的值
col ksppinm format a col ksppstvl format a select ksppinm ksppstvl from x$ksppi pi x$ksppcv cv where cv indx=pi indx and pi ksppinm like \\_% escape \\ and pi ksppinm like %meer% ;
求系统中较大的latch
select name sum(gets) sum(misses) sum(sleeps) sum(wait_time) from v$latch_children group by name having sum(gets) > order by ;
求归档日志的切换频率(生产系统可能时间会很长)
select start_recid start_time end_recid end_time minutes from (select test * rownum as rn from (select b recid start_recid to_char(b first_time yyyy mm dd hh :mi:ss ) start_time a recid end_recid to_char(a first_time yyyy mm dd hh :mi:ss ) end_time round(((a first_time b first_time)* )* ) minutes from v$log_history a v$log_history b where a recid=b recid+ and b first_time > sysdate order by a first_time desc) test) y where y rn <
求回滚段正在处理的事务
select a name b xacts c sid c serial# d sql_text from v$rollname a v$rollstat b v$session c v$sqltext d v$transaction e where a usn=b usn and b usn=e xidusn and c taddr=e addr and c sql_address=d address and c sql_hash_value=d hash_value order by a name c sid d piece;
求出无效的对象
select alter procedure ||object_name|| pile; from dba_objects where status= INVALID and wner= & and object_type in ( PACKAGE PACKAGE BODY ); / select owner object_name object_type status from dba_objects where status= INVALID ;
求process/session的状态
select p pid p spid s program s sid s serial# from v$process p v$session s where s paddr=p addr;
求当前session的状态
select sn name ms value from v$mystat ms v$statname sn where ms statistic#=sn statistic# and ms value > ;
求表的索引信息
select ui table_name ui index_name from user_indexes ui user_ind_columns uic where ui table_name=uic table_name and ui index_name=uic index_name and ui table_name like &table_name% and uic column_name= &column_name ;
显示表的外键信息
col search_condition format a select table_name constraint_name from user_constraints where constraint_type = R and constraint_name in (select constraint_name from user_cons_columns where column_name= & ); select rpad(child table_name ) child_tablename rpad(cp column_name ) referring_column rpad(parent table_name ) parent_tablename rpad(pc column_name ) referred_column rpad(child constraint_name ) constraint_name from user_constraints child user_constraints parent user_cons_columns cp user_cons_columns pc where child constraint_type = R and child r_constraint_name = parent constraint_name and child constraint_name = cp constraint_name and parent constraint_name = pc constraint_name and cp position = pc position and child table_name = &table_name order by child owner child table_name child constraint_name cp position;
显示表的分区及子分区(user_tab_subpartitions)
col table_name format a col partition_name format a col high_value format a select table_name partition_name HIGH_VALUE from user_tab_partitions where table_name= &table_name
使用dbms_xplan生成一个执行计划
explain plan set statement_id = &sql_id for &sql; select * from table(dbms_xplan display);
求某个事务的重做信息(bytes)
select s name m value from v$mystat m v$statname s where m statistic#=s statistic# and s name like %redo size% ;
求cache中缓存超过其 %的对象
select o owner o object_type o object_name count(b objd) from v$bh b dba_objects o where b objd = o object_id group by o owner o object_type o object_name having count(b objd) > (select to_number(value)* from v$parameter where name = db_block_buffers );
求谁阻塞了某个session( g)
select sid username event blocking_session seconds_in_wait wait_time from v$session where state in ( WAITING ) and wait_class != Idle ;
求session的OS进程ID
col program format a select p spid OS Thread b name Name User s program from v$process p v$session s v$bgprocess b where p addr = s paddr and p addr = b paddr UNION ALL select p spid OS Thread s username Name User s program from v$process p v$session s where p addr = s paddr and s username is not null;
查会话的阻塞
col user_name format a select /*+ rule */ lpad( decode(l xidusn ))||l oracle_username user_name o owner o object_name s sid s serial# from v$locked_object l dba_objects o v$session s where l object_id=o object_id and l session_id=s sid order by o object_id xidusn desc ; col username format a col lock_level format a col owner format a col object_name format a select /*+ rule */ s username decode(l type tm table lock tx row lock null) lock_level o owner o object_name s sid s serial# from v$session s v$lock l dba_objects o where l sid = s sid and l id = o object_id(+) and s username is not null ;
求等待的事件及会话信息/求会话的等待及会话信息
select se sid s username se event se total_waits se time_waited se average_wait from v$session s v$session_event se where s username is not null and se sid=s sid and s status= ACTIVE and se event not like %SQL*Net% order by s username; select s sid s username sw event sw wait_time sw state sw seconds_in_wait from v$session s v$session_wait sw where s username is not null and sw sid=s sid and sw event not like %SQL*Net% order by s username;
cha138/Article/program/SQL/201311/16149相关参考
求会话等待的file_id/block_id coleventformata colptextformata colptextformata colptextformata select
数据库人员手边系列:SQLServer安全列表 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 确
知识大全 SQL Server数据库管理员(DBA)的工作内容
SQLServer数据库管理员(DBA)的工作内容 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!
数据库手册:速查Oracle函数列表 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! PL/SQL
实例讲解如何返回网络中的SQLServer列表 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!&nb
知识大全 SQL Server 数据库管理常用的SQL和T-SQL语句[1]
SQLServer数据库管理常用的SQL和T-SQL语句[1] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
知识大全 用ADO管理SQL Server数据库及其设备[1]
用ADO管理SQLServer数据库及其设备[1] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!&
知识大全 SQL Server 数据库管理常用的SQL和T-SQL语句[3]
SQLServer数据库管理常用的SQL和T-SQL语句[3] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
知识大全 SQL Server 数据库管理常用的SQL和T-SQL语句[2]
SQLServer数据库管理常用的SQL和T-SQL语句[2] 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来
SQLSever2008R2数据库管理 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 一预备知识