ORACLE關於鎖表查詢的部分SQL

2022-02-01 01:27:43 字數 3121 閱讀 6114

--

查詢表空間名稱和大小

select upper (f.tablespace_name) "表空間名",

d.tot_grootte_mb "表空間大小(m)",

d.tot_grootte_mb - f.total_bytes "已使用空間(m)",

to_char (round ((d.tot_grootte_mb - f.total_bytes) / d.tot_grootte_mb * 100, 2), '990.99') "使用比",

f.total_bytes "空閒空間(m)",

f.max_bytes "最大塊(m)"

from (  select tablespace_name,

round (sum (bytes) / (1024 * 1024), 2) total_bytes,

round (max (bytes) / (1024 * 1024), 2) max_bytes

from sys.dba_free_space

group by tablespace_name) f,

(  select dd.tablespace_name,

round (sum (dd.bytes) / (1024 * 1024), 2) tot_grootte_mb

from sys.dba_data_files dd

group by dd.tablespace_name) d

where d.tablespace_name = f.tablespace_name

order by 4 desc;

--檢視資料庫引起鎖表的

sql語句:

select a.username,

a.machine,

a.program,

a.sid,

a.serial#,

a.status,

c.piece,

c.sql_text

from v$session a,

v$sqltext c

where     a.sid in (select distinct t2.sid

from v$locked_object t1,

v$session t2

where t1.session_id = t2.sid)

and a.sql_address = c.address(+)

order by c.piece;

--檢視資料庫鎖的情況必須要有

dba許可權,可以使用一下

sql

語句:select object_id, session_id, locked_mode from v$locked_object;

select t2.username,

t2.sid,

t2.serial#,

t2.logon_time

from v$locked_object t1, v$session t2

where t1.session_id = t2.sid

order by t2.logon_time;

--檢視被鎖的表

select p.spid,

a.serial#,

c.object_name,

b.session_id,

b.oracle_username,

b.os_user_name

from v$process p,

v$session a,

v$locked_object b,

all_objects c

where     p.addr = a.paddr

and a.process = b.process

and c.object_id = b.object_id;

--殺掉程序

alter system kill session 'sid,serial#';

--檢視連線數

select count (*) from v$session;

--檢視併發連線數

select count(*) from v$session where status='active';

--檢視連線的程序

select sid, serial#, username, osuser from v$session;

--檢視資料庫使用的裸裝置

select *

from dba_data_files

order by file_name;

select *

from dba_temp_files

order by file_name;

select *

from v$controlfile

order by file_name;

select *

from v$logfile;

--具體的方法是查詢

dba_data_files

,dba_temp_files

,v$controlfile

和v$logfile

看這四類檔案具體占用的裸裝置

--查詢所有使用者表使用大小的前三十名

select * from (select segment_name,bytes from dba_segments where owner = user order by bytes desc ) where rownum <= 30;

--以下的

sql語句列出當前資料庫建立的會話情況

: select sid,serial#,username,program,machine,status from v$session;

--如果

dba要手工斷開某個會話,則執行

: alter system kill session 'sid,serial#';

--注意,上例中

sid為1到

7(username

列為空)

的會話,是

oracle

的後台程序,不要對這些會話進行任何操作。

--查詢表空間有那些表

: select table_name from all_tables where tablespace_name= 'temp';

ORACLE關於鎖表查詢的部分SQL

查詢表空間名稱和大小 select upper f.tablespace name 表空間名 d.tot grootte mb 表空間大小 m d.tot grootte mb f.total bytes 已使用空間 m to char round d.tot grootte mb f.total ...

關於鎖表查詢的部分SQL

查詢表空間名稱和大小 select upper f.tablespace name 表空間名 d.tot grootte mb 表空間大小 m d.tot grootte mb f.total bytes 已使用空間 m to char round d.tot grootte mb f.total ...

ORACLE鎖表查詢

select rule lpad decode l.xidusn 0,3,0 l.oracle username user name,o.owner,o.object name,o.object type,s.sid,s.serial from v locked object l,dba objec...