本篇文章為大家帶來了關於Oracle的相關知識,其中主要整理了資料字典、資料字典視圖及動態效能檢視的相關問題,資料字典記錄資料庫最基本的信息,包括資料字典基本表和資料字典視圖,下面一起來看一下,希望對大家有幫助。
推薦教學:《Oracle影片教學》
資料字典記錄資料庫最基本的信息,包括資料字典基本表和資料字典檢視;資料字典基本表由$ORACLE_HOME\RDBMS\ADMIN\sql.bsq建立
# 資料字典基本表,屬於sys用戶,存放在system表空間,用戶不能手動去修改資料字典基本表;
為了簡化對資料字典基本表的使用,oracle提供了資料字典視圖,也為資料字典視圖創建了公有同義詞,方便使用者使用,資料字典視圖和同義詞的建立透過catalog.sql
USER_類型的視圖表示目前登入使用者擁有的資訊;
ALL_類型的視圖表示目前登入使用者有權限看到的資訊;
DBA_類型的視圖表示資料庫管理員能夠看到的資訊
如:
對應了2個資料庫對象,一個是資料字典視圖,一個是同義詞,而且是先基於資料字典表建立資料字典視圖,然後為視圖建立了一個同名的同義詞
查詢USER_TABLES對應的資料庫物件:
select * from dba_objects d where d.OBJECT_NAME='USER_TABLES';
查詢USER_TABLES對應的檢視:
select * from dba_views d where d.view_name='USER_TABLES';
# 查詢USER_TABLES對應檢視的建立語句:
SQL> SET LONG 10000;SQL> select d.text from dba_views d where d.view_name='USER_TABLES';TEXT--------------------------------------------------------------------------------select o.name, decode(bitand(t.property,2151678048), 0, ts.name, decode(t.ts#, 0, null, ts.name)), decode(bitand(t.property, 1024), 0, null, co.name), decode((bitand(t.property, 512)+bitand(t.flags, 536870912)), 0, null, co.name), decode(bitand(t.trigflag, 1073741824), 1073741824, 'UNUSABLE', 'VALID'), decode(bitand(t.property, 32+64), 0, mod(t.pctfree$, 100), 64, 0, null), decode(bitand(ts.flags, 32), 32, to_number(NULL), decode(bitand(t.property, 32+64), 0, t.pctused$, 64, 0, null)), decode(bitand(t.property, 32), 0, t.initrans, null), decode(bitand(t.property, 32), 0, t.maxtrans, null), decode(bitand(t.property, 17179869184), 17179869184, ds.initial_stg * ts.blocksize, s.iniexts * ts.blocksize), decode(bitand(t.property, 17179869184), 17179869184, ds.next_stg * ts.blocksize, s.extsize * ts.blocksize), decode(bitand(t.property, 17179869184), 17179869184, ds.minext_stg, s.minexts), decode(bitand(t.property, 17179869184), 17179869184, ds.maxext_stg, s.maxexts), decode(bitand(ts.flags, 3), 1, to_number(NULL), decode(bitand(t.property, 17179869184), 17179869184, ds.pctinc_stg, s.extpct)), decode(bitand(ts.flags, 32), 32, to_number(NULL), decode(bitand(o.flags, 2), 2, 1, decode(bitand(t.property, 17179869184), 17179869184, ds.frlins_stg, decode(s.lists, 0, 1, s.lists)))), decode(bitand(ts.flags, 32), 32, to_number(NULL), decode(bitand(o.flags, 2), 2, 1, decode(bitand(t.property, 17179869184), 17179869184, ds.maxins_stg, decode(s.groups, 0, 1, s.groups)))), decode(bitand(t.property, 32+64), 0, decode(bitand(t.flags, 32), 0, 'YES', 'NO'), null), decode(bitand(t.flags,1), 0, 'Y', 1, 'N', '?'), t.rowcnt, decode(bitand(t.property, 64), 0, t.blkcnt, null), decode(bitand(t.property, 64), 0, t.empcnt, null), decode(bitand(t.property, 64), 0, t.avgspc, null), t.chncnt, t.avgrln, t.avgspc_flb, decode(bitand(t.property, 64), 0, t.flbcnt, null), lpad(decode(t.degree, 32767, 'DEFAULT', nvl(t.degree,1)),10), lpad(decode(t.instances, 32767, 'DEFAULT', nvl(t.instances,1)),10), lpad(decode(bitand(t.flags, 8), 8, 'Y', 'N'),5), decode(bitand(t.flags, 6), 0, 'ENABLED', 'DISABLED'), t.samplesize, t.analyzetime, decode(bitand(t.property, 32), 32, 'YES', 'NO'), decode(bitand(t.property, 64), 64, 'IOT', decode(bitand(t.property, 512), 512, 'IOT_OVERFLOW', decode(bitand(t.flags, 536870912), 536870912, 'IOT_MAPPING', null))), decode(bitand(o.flags, 2), 0, 'N', 2, 'Y', 'N'), decode(bitand(o.flags, 16), 0, 'N', 16, 'Y', 'N'), decode(bitand(t.property, 8192), 8192, 'YES', decode(bitand(t.property, 1), 0, 'NO', 'YES')), decode(bitand(o.flags, 2), 2, 'DEFAULT', decode(bitand(decode(bitand(t.property, 17179869184), 17179869184, ds.bfp_stg, s.cachehint), 3), 1, 'KEEP', 2, 'RECYCLE', 'DEFAULT')), decode(bitand(o.flags, 2), 2, 'DEFAULT', decode(bitand(decode(bitand(t.property, 17179869184), 17179869184, ds.bfp_stg, s.cachehint), 12)/4, 1, 'KEEP', 2, 'NONE', 'DEFAULT')), decode(bitand(o.flags, 2), 2, 'DEFAULT', decode(bitand(decode(bitand(t.property, 17179869184), 17179869184, ds.bfp_stg, s.cachehint), 48)/16, 1, 'KEEP', 2, 'NONE', 'DEFAULT')), decode(bitand(t.flags, 131072), 131072, 'ENABLED', 'DISABLED'), decode(bitand(t.flags, 512), 0, 'NO', 'YES'), decode(bitand(t.flags, 256), 0, 'NO', 'YES'), decode(bitand(o.flags, 2), 0, NULL, decode(bitand(t.property, 8388608), 8388608, 'SYS$SESSION', 'SYS$TRANSACTION')), decode(bitand(t.flags, 1024), 1024, 'ENABLED', 'DISABLED'), decode(bitand(o.flags, 2), 2, 'NO', decode(bitand(t.property, 2147483648), 2147483648, 'NO', decode(ksppcv.ksppstvl, 'TRUE', 'YES', 'NO'))), decode(bitand(t.property, 1024), 0, null, cu.name), decode(bitand(t.flags, 8388608), 8388608, 'ENABLED', 'DISABLED'), case when (bitand(t.property, 32) = 32) then null when (bitand(t.property, 17179869184) = 17179869184) then decode(bitand(ds.flags_stg, 4), 4, 'ENABLED', 'DISABLED') else decode(bitand(s.spare1, 2048), 2048, 'ENABLED', 'DISABLED') end, case when (bitand(t.property, 32) = 32) then null when (bitand(t.property, 17179869184) = 17179869184) then decode(bitand(ds.flags_stg, 4), 4, case when bitand(ds.cmpflag_stg, 3) = 1 then 'BASIC' when bitand(ds.cmpflag_stg, 3) = 2 then 'OLTP' else decode(ds.cmplvl_stg, 1, 'QUERY LOW', 2, 'QUERY HIGH', 3, 'ARCHIVE LOW', 'ARCHIVE HIGH') end, null) else decode(bitand(s.spare1, 2048), 0, null, case when bitand(s.spare1, 16777216) = 16777216 -- 0x1000000 then 'OLTP' when bitand(s.spare1, 100663296) = 33554432 -- 0x2000000 then 'QUERY LOW' when bitand(s.spare1, 100663296) = 67108864 -- 0x4000000 then 'QUERY HIGH' when bitand(s.spare1, 100663296) = 100663296 -- 0x2000000+0x4000000 then 'ARCHIVE LOW' when bitand(s.spare1, 134217728) = 134217728 -- 0x8000000 then 'ARCHIVE HIGH' else 'BASIC' end) end, decode(bitand(o.flags, 128), 128, 'YES', 'NO'), decode(bitand(t.trigflag, 2097152), 2097152, 'YES', 'NO'), decode(bitand(t.property, 17179869184), 17179869184, 'NO', decode(bitand(t.property, 32), 32, 'N/A', 'YES')), decode(bitand(t.property,16492674416640),2199023255552,'FORCE', 4398046511104,'MANUAL','DEFAULT')from sys.ts$ ts, sys.seg$ s, sys.obj$ co, sys.tab$ t, sys.obj$ o, sys.deferred_stg$ ds, sys.obj$ cx, sys.user$ cu, x$ksppcv ksppcv, x$ksppi ksppiwhere o.owner# = userenv('SCHEMAID') and o.obj# = t.obj# and bitand(t.property, 1) = 0 and bitand(o.flags, 128) = 0 and t.bobj# = co.obj# (+) and t.ts# = ts.ts# and t.file# = s.file# (+) and t.block# = s.block# (+) and t.ts# = s.ts# (+) and t.obj# = ds.obj# (+) and t.dataobj# = cx.obj# (+) and cx.owner# = cu.user# (+) and ksppi.indx = ksppcv.indx and ksppi.ksppinm = '_dml_monitoring_enabled'
查詢同義字:
select * from dba_synonyms d where d.synonym_name='USER_TABLES'
查詢目前登入使用者擁有的表格
#儲存資料庫中每時每刻都在變化的訊息,主要是資料庫的活動狀態資訊。把儲存在記憶體裡的信息,和儲存在控製文件裡的信息,以視圖的形式展現出來;
初始化參數檔中所有項目的值
目前程序的資訊
有關會話的資訊
基於目前操作會話進行的系統統計
從控制檔案擷取有關重做日誌群組的資訊
有關實例重做日誌組檔名及其位置的資訊
#目前程序已取得且正在請求的鎖定資訊
資料庫事務資訊
記錄所有動態效能檢視的定義資訊
推薦教學:《Oracle影片教學》
以上是oracle資料字典、資料字典視圖及動態效能視圖(總結分享)的詳細內容。更多資訊請關注PHP中文網其他相關文章!