oracle常用語句

2021-06-18 23:10:00 字數 2622 閱讀 8382

-- 查詢鎖定表

select l.session_id sid,

s.serial#,

l.locked_mode,

l.oracle_username,

l.os_user_name,

s.machine,

s.terminal,

o.object_name,

s.logon_time   

from v$locked_object l, all_objects o, v$session s

where l.object_id = o.object_id

and l.session_id = s.sid

order by sid, s.serial#;

-- 解鎖

alter system kill session 'sid,serial#';

--查詢表空間使用情況

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 1

--查詢表結構

select * from (

select a.table_name 表名,

c.comments 表注釋,

a.column_name 列名,

a.comments 注釋,

b.data_type 型別,

b.data_length 長度,

b.nullable 可為空

from user_col_comments a, cols b,user_tab_comments c

where a.table_name = b.table_name(+)

and a.column_name = b.column_name(+)

and a.table_name = c.table_name(+)

order by a.table_name,a.column_name)

檢視oracle使用者執行的sql語句歷史記錄

2011-07-27 12:02:07 我來說兩句 收藏 我要投稿

平時用得少,儲存一下以後檢視。

select * from v$sqlarea t where t.parsing_schema_name in ('使用者名稱') order by t.last_active_time desc

使用者名稱需要大寫

select * from v$sqlarea t order by t.last_active_time desc

-------oracle 檢視已經執行過的sql 這些是存在共享池中的 --------->

select * from v$sqlarea t order by t.last_active_time desc

-----------檢視oracle會話----------------------------》

select * from v$session t order by t.last_active_time desc

-------------檢視oracle的許可權角色------------------------------>

select * from dba_role_privs; 授予使用者和其他角色的角色

select * from dba_sys_privs; 授予使用者和其他角色的系統許可權

select * from dba_tab_privs; 資料庫中物件的所有授權

select * from user_role_privs; 檢視當前使用者的角色

oracle後台過程加密 

wrap iname=c:test.pck

oracle 常用語句

oracle 產看表空間 select total.name tablespace name free space,total space free space used space,total space from select tablespace name,sum bytes 1024 102...

oracle常用語句

drop tablespace crm online space including contents and datafiles 刪除表空間 drop user wuliu01 cascade 刪除使用者 exp orcl file d dmp 匯出資料庫 imp orcl file e alen...

oracle 常用語句

oracle 常用語句 查詢表的大小 select t.owner,t.segment name,sum t.blocks 8 1024 m as s,t.segment type from dba segments t where t.owner user name group by t.owne...