DBA常用sql(二)
session状态:
STATUS VARCHAR2(8) Status of the session:
ACTIVE - Session currently executing SQL
INACTIVE - sql及其session没有释放或正常退出......
KILLED - Session marked to be killed
CACHED - Session temporarily cached for use by Oracle*XA
SNIPED - Session inactive, waiting on the client
查询数据库中持锁和等待锁的用户信息
select distinct o.object_name, sh.sid "SID", sh.SERIAL# "SERIAL", sh.username||'('||sh.sid||','||sh.SERIAL#||')' "Holder",
sw.username||'('||sw.sid||','||sw.SERIAL#||')' "Waiter",
decode(lh.lmode, 1, 'null', 2,
'row share', 3, 'row exclusive', 4, 'share',
5, 'share row exclusive' , 6, 'exclusive') "Lock Type"
from v$session sw, v$lock lw,all_objects o, v$session sh, v$lock lh
where lh.id1 = o.object_id
and lh.id1 = lw.id1
and sh.sid = lh.sid
and sw.sid = lw.sid
and sh.lockwait is null
and sw.lockwait is not null
and lh.type = 'TM'
and lw.type = 'TM';
select /*+ NO_MERGE(a) NO_MERGE(b) NO_MERGE(c) */ 'Wait' "Status", a.username, a.machine, a.sid, a.serial#, a.last_call_et "Seconds", b.id1, c.sql_text "SQL"
from v$session a, v$lock b, v$sqltext c
where a.username is not null
and a.lockwait = b.kaddr
and c.hash_value =a.sql_hash_value
union
select /*+ NO_MERGE(a) NO_MERGE(b) NO_MERGE(c) */ 'Lock' "Status", a.username, a.machine, a.sid, a.serial#, a.last_call_et "Seconds", b.id1, c.sql_text "SQL"
from v$session a, v$lock b, v$sqltext c
where b.id1 in
(select /*+ NO_MERGE(d) NO_MERGE(e) */ distinct e.id1
from v$session d, v$lock e
where d.lockwait = e.kaddr)
and a.username is not null
and a.sid = b.sid
and b.request=0
and c.ha
相关文档:
现在发现SQL语句确实是太强大了,以后遇到问题要尽量先好好思考下,不要按照最笨的方法来做!
1.从tblFaultDetailTemp表中,找到ID=14的项,并将所列出的四个字段的值拷贝到tblFaultDetail表中
Insert into tblFaultDetail(Code,FileType,FaultCode,FaultRect) select Code,FileType,FaultCode,FaultRect from tblF ......
/*--text字段的替换处理
--*/
--创建数据测试环境
--create table #tb(aa text)
declare @s_str varchar(8000),@d_str varchar(8000), --定义替换的字符串
......
(1) 选择最有效率的表名顺序(只在基于规则的优化器中有效):
ORACLE的解析器按照从右到左的顺序处理from子句中的表名,from子句中写在最后的表(基础表 driving table)将被最先处理,在from子句中包含多个表的情况下,你必须选择记录条数最少的表作为基础表。如果有3个以上的表连接查询, 那 ......
手动清理
1、打开查询分析器,输入命令DUMP TRANSACTION 数据库名 WITH NO_LOG
2、再打开企业管理器--右键你要压缩的数据库--所有任务--收缩数据库--收缩文件--选择日志文件--在收缩方式里选择收缩至: ,这里会给出一个允许收缩到的最小M数,直接输入这个数,确定就可以了。
如1)
自动清理
企业管理器-》管理-》sql ......
Private Sub CommandButton1_Click()
Worksheets("Sheet2").Select
Cells.Select
Selection.Delete Shift:=xlUp
Range("A1").Select
'清除在Excel中的数据,确保导入信息不出现与原Excel数据进行叠加
Dim cnnConnect As Object
Dim rstR ......