select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;
alter system kill session '7479,45865'
select 'alter table ' || a.owner ||'.'||a.table_name ||' modify usr_city_nm varchar2(32) ; ' from all_tab_columns a where a.column_name = 'usr_city_nm'
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/1024 "空閒空間(g)",
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;
select a.owner 所屬使用者,
a.table_name 表名,
e.table_comments 表中文名,
a.column_name 欄位名,
e.column_comments 字段中文名,
a.data_type 字段型別,
a.字段長度,
a.欄位精度,
a.是否為空,
a.建立日期,
a.最後修改日期,
case
when a.owner = d.owner and a.table_name = d.table_name and
a.column_name = d.column_name then
'主鍵'
else
end 是否主鍵
from (select a.owner,
a.table_name,
b.column_name,
b.data_type,
case
when b.data_precision is null then
b.data_length
else
data_precision
end 字段長度,
data_scale 字段精度,
decode(nullable, 'y', '√', 'n', '×') 是否為空,
c.created 建立日期,
c.last_ddl_time 最後修改日期
from all_tables a, all_tab_columns b, all_objects c
where a.table_name = b.table_name
and a.owner = b.owner
and a.owner = c.owner
and a.table_name = c.object_name
-- and a.owner = 'cdbadm' --此處使用者名稱可以更改,但必須大寫英文
and c.object_type = 'table') a
left join (select a.owner, a.table_name, a.column_name, a.constraint_name
from user_cons_columns a, user_constraints b
where a.constraint_name = b.constraint_name
and b.constraint_type = 'p') d
on a.owner = d.owner
and a.table_name = d.table_name
and a.column_name = d.column_name
left join (select cl.owner,
t.table_name,
t.comments table_comments,
cl.column_name,
cl.comments column_comments
from all_col_comments cl, all_tab_comments t
where cl.owner = t.owner
and cl.table_name = t.table_name) e
on a.owner = e.owner
and a.table_name = e.table_name
and a.column_name = e.column_name
order by a.owner, a.table_name;
oracle系統表的查詢
檢視當前使用者的預設表空間 sql select username,default tablespace from user users 檢視當前使用者的角色 sql select from user role privs 檢視當前使用者的系統許可權和表級許可權 sql select from us...
Oracle系統表查詢
資料字典dict總是屬於oracle使用者sys的。1 使用者 select username from dba users 改口令 alter user spgroup identified by spgtest 2 表空間 select from dba data files select fr...
Oracle中查詢表的資訊
查詢oracle表的資訊 url url 根據表名查詢外來鍵表,外來鍵名稱 select u1.constraint name,u1.table name as p table,u2.table name from user constraints u1,user constraints u2 wh...