select
*from v$lock
;select
*from v$sqlarea;
select
*from v$session
;select
*from v$process ;
select
*from v$locked_object;
select
*from all_objects;
select
*from v$session_wait;
select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_objects b where b.object_id = a.object_id;
select b.username,b.sid,b.
serial
#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
select sid,
serial
#, username, osuser from v$session;
select s.sid, s.
serial
#, s.username, s.schemaname, s.osuser, s.process, s.machine,
s.terminal, s.logon_time, l.
type
from v$session s, v$lock l
where s.sid = l.sid
and s.username is
notnull
order
by sid;
這個語句將查詢到資料庫中所有的dml語句產生的鎖,還可以發現,
任何dml語句其實產生了兩個鎖,乙個是表鎖,乙個是行鎖。
alter system kill
session
'210,11562'
;
select a.username,
d.object_name,
a.sid,
a.serial
#, c.sql_text,
a.status
, a.sql_id
from v$sql c, v$session a, v$locked_object b, dba_objects d
where a.sql_id = c.sql_id(+)
and a.sid = b.session_id
and b.object_id = d.object_id
and d.owner=upper(
'edbadm'
)and d.object_name = upper(
'dwt_hold_gls'
);
select substr(s2.username,1,
12)"鎖人者(holding user)"
, substr(s2.osuser,1,
8)"鎖人者(osuser)"
, s2.machine,
s1.program ,
substr(to_char(h.session_id),1
,5)"鎖人者(sid)"
, p2.spid "鎖人者(spid)"
, d.sql_text,
substr(s1.username,1,
12)"被鎖(waiting user)"
, substr(s1.osuser,1,
8)"被鎖(osuser)"
, s1.machine ,
substr(to_char(w.session_id),1
,5)"被鎖(sid)"
, p1.spid "被鎖(spid)"
from sys.v_$process p1 ,
sys.v_$process p2 ,
sys.v_$session s1 ,
sys.v_$session s2 ,
dba_locks w ,
dba_locks h,
v$sql d
where h.mode_held !=
'none'
and h.mode_held !=
'null'
and w.mode_requested !=
'none'
and w.lock_type(+)
= h.lock_type
and w.lock_id1(+)
= h.lock_id1
and w.lock_id2(+)
= h.lock_id2
and w.session_id = s1.sid(+)
and h.session_id = s2.sid(+)
and s1.paddr = p1.addr(+)
and s2.paddr = p2.addr(+)
and s1.sql_id = d.sql_id;``
`
oracle 鎖表相關處理
kill session語句 alter system kill session 50,492 以下幾個為相關表 select from v lock select from v sqlarea select from v session select from v process select f...
Oracle查詢建表相關
建立表 create table user 建立user表,號中區分大小寫,預設為大寫 id int primary key,primary key 主鍵關鍵字 name varchar 10 unique not null,unique 不許重複關鍵字,not null 不許為空關鍵字 age n...
oracle表相關操作
新增字段 可以單個,也可以多個 alter table 表名add 列名 修改字段 alter table 表名modify 列名 刪除字段 alter table 表名drop column 列名 新增主鍵 alter table 表名add constraint pk 約束名primary ke...