Oracle常用數(shù)據(jù)字典與動(dòng)態(tài)性能視圖_第1頁(yè)
Oracle常用數(shù)據(jù)字典與動(dòng)態(tài)性能視圖_第2頁(yè)
Oracle常用數(shù)據(jù)字典與動(dòng)態(tài)性能視圖_第3頁(yè)
Oracle常用數(shù)據(jù)字典與動(dòng)態(tài)性能視圖_第4頁(yè)
Oracle常用數(shù)據(jù)字典與動(dòng)態(tài)性能視圖_第5頁(yè)
已閱讀5頁(yè),還剩15頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Oracle常用數(shù)據(jù)字典表查看當(dāng)前用戶的缺省表空間SQL>select username,default_tablespace from user_users;查看當(dāng)前用戶的角色SQL>select * from user_role_privs;查看當(dāng)前用戶的系統(tǒng)權(quán)限和表級(jí)權(quán)限SQL>select * from user_sys_privs;SQL>select * from user_tab_privs;查看用戶下所有的表SQL>select * from user_tables;查看用戶下所有的表的列屬性SQL>select * from USER_TA

2、B_COLUMNS where table_name=:table_Name;顯示用戶信息(所屬表空間select default_tablespace,temporary_tablespacefrom dba_users where username='GAME'1、用戶查看當(dāng)前用戶的缺省表空間SQL>select username,default_tablespace from user_users;查看當(dāng)前用戶的角色SQL>select * from user_role_privs;查看當(dāng)前用戶的系統(tǒng)權(quán)限和表級(jí)權(quán)限SQL>select * from us

3、er_sys_privs;SQL>select * from user_tab_privs;顯示當(dāng)前會(huì)話所具有的權(quán)限SQL>select * from session_privs;顯示指定用戶所具有的系統(tǒng)權(quán)限SQL>select * from dba_sys_privs where grantee='GAME'顯示特權(quán)用戶select * from v$pwfile_users;顯示用戶信息(所屬表空間select default_tablespace,temporary_tablespacefrom dba_users where username='

4、;GAME'顯示用戶的PROFILEselect profile from dba_users where username='GAME'2、表查看用戶下所有的表SQL>select * from user_tables;查看名稱包含log字符的表SQL>select object_name,object_id from user_objectswhere instr(object_name,'LOG'>0;查看某表的創(chuàng)建時(shí)間SQL>select object_name,created from user_objects wher

5、e object_name=upper('&table_name'查看某表的大小SQL>select sum(bytes/(1024*1024 as "size(M" from user_segmentswhere segment_name=upper('&table_name'查看放在Oracle的內(nèi)存區(qū)里的表SQL>select table_name,cache from user_tables where instr(cache,'Y'>0;3、索引查看索引個(gè)數(shù)和類別SQL>sel

6、ect index_name,index_type,table_name from user_indexes order by table_name;查看索引被索引的字段SQL>select * from user_ind_columns where index_name=upper('&index_name'查看索引的大小SQL>select sum(bytes/(1024*1024 as "size(M" from user_segmentswhere segment_name=upper('&index_name&#

7、39;4、序列號(hào)查看序列號(hào),last_number是當(dāng)前值SQL>select * from user_sequences;5、視圖查看視圖的名稱SQL>select view_name from user_views;查看創(chuàng)建視圖的select語(yǔ)句SQL>set view_name,text_length from user_views;SQL>set long 2000; 說(shuō)明:可以根據(jù)視圖的text_length值設(shè)定set long 的大小SQL>select text from user_views where view_name=upper('

8、&view_name'6、同義詞查看同義詞的名稱SQL>select * from user_synonyms;7、約束條件查看某表的約束條件SQL>select constraint_name, constraint_type,search_condition, r_constraint_namefrom user_constraints where table_name = upper('&table_name'SQL>select c.constraint_name,c.constraint_type,cc.column_name

9、from user_constraints c,user_cons_columns ccwhere c.owner = upper('&table_owner' and c.table_name = upper('&table_name' and c.owner = cc.owner and c.constraint_name = cc.constraint_nameorder by cc.position;8、存儲(chǔ)函數(shù)和過(guò)程查看函數(shù)和過(guò)程的狀態(tài)SQL>select object_name,status from user_objects

10、where object_type='FUNCTION'SQL>select object_name,status from user_objects where object_type='PROCEDURE'查看函數(shù)和過(guò)程的源代碼SQL>select text from all_source where owner=user and name=upper('&plsql_name' 常用的數(shù)據(jù)字典:dba_data_files:通常用來(lái)查詢關(guān)于數(shù)據(jù)庫(kù)文件的信息dba_db_links:包括數(shù)據(jù)庫(kù)中的所有數(shù)據(jù)庫(kù)鏈路,也就是da

11、tabaselinks。dba_extents:數(shù)據(jù)庫(kù)中所有分區(qū)的信息dba_free_space:所有表空間中的自由分區(qū)dba_indexs:關(guān)于數(shù)據(jù)庫(kù)中所有索引的描述dba_ind_columns:在所有表及聚集上壓縮索引的列dba_objects:數(shù)據(jù)庫(kù)中所有的對(duì)象dba_rollback_segs:回滾段的描述dba_segments:所有數(shù)據(jù)庫(kù)段分段的存儲(chǔ)空間dba_synonyms:關(guān)于同義詞的信息查詢dba_tables:數(shù)據(jù)庫(kù)中所有數(shù)據(jù)表的描述dba_tabespaces:關(guān)于表空間的信息dba_tab_columns:所有表描述、視圖以及聚集的列dba_tab_grants/

12、privs:對(duì)象所授予的權(quán)限dba_ts_quotas:所有用戶表空間限額dba_users:關(guān)于數(shù)據(jù)的所有用戶的信息dba_views:數(shù)據(jù)庫(kù)中所有視圖的文本常用的動(dòng)態(tài)性能視圖:v$datafile:數(shù)據(jù)庫(kù)使用的數(shù)據(jù)文件信息v$librarycache:共享池中SQL語(yǔ)句的管理信息v$lock:通過(guò)訪問(wèn)數(shù)據(jù)庫(kù)會(huì)話,設(shè)置對(duì)象鎖的所有信息v$log:從控制文件中提取有關(guān)重做日志組的信息v$logfile有關(guān)實(shí)例重置日志組文件名及其位置的信息v$parameter:初始化參數(shù)文件中所有項(xiàng)的值v$process:當(dāng)前進(jìn)程的信息v$rollname:回滾段信息v$rollstat:聯(lián)機(jī)回滾段統(tǒng)計(jì)信息v

13、$rowcache:內(nèi)存中數(shù)據(jù)字典活動(dòng)/性能信息v$session:有關(guān)會(huì)話的信息v$sesstat:在v$session中報(bào)告當(dāng)前會(huì)話的統(tǒng)計(jì)信息v$sqlarea:共享池中使用當(dāng)前光標(biāo)的統(tǒng)計(jì)信息,光標(biāo)是一塊內(nèi)存區(qū)域,有Oracle處理SQL語(yǔ)句時(shí)打開。v$statname:在v$sesstat中報(bào)告各個(gè)統(tǒng)計(jì)的含義v$sysstat:基于當(dāng)前操作會(huì)話進(jìn)行的系統(tǒng)統(tǒng)計(jì)v$waitstat:出現(xiàn)一個(gè)以上會(huì)話訪問(wèn)數(shù)據(jù)庫(kù)的數(shù)據(jù)時(shí)的詳細(xì)情況。當(dāng)有一個(gè)以上的會(huì)話訪問(wèn)同一信息時(shí),可出現(xiàn)等待情況。總結(jié)了一下這些,徹底區(qū)別了視圖與數(shù)據(jù)字典,也不那么容易混淆。嘿嘿!常用SQL查詢:1、查看表空間的名稱及大小sele

14、ct t.tablespace_name, round(sum(bytes/(1024*1024,0 ts_sizefrom dba_tablespaces t, dba_data_files dwhere t.tablespace_name = d.tablespace_namegroup by t.tablespace_name;2、查看表空間物理文件的名稱及大小select tablespace_name, file_id, file_name,round(bytes/(1024*1024,0 total_spacefrom dba_data_filesorder by tablespa

15、ce_name;3、查看回滾段名稱及大小select segment_name, tablespace_name, r.status,(initial_extent/1024 InitialExtent,(next_extent/1024 NextExtent,max_extents, v.curext CurExtentFrom dba_rollback_segs r, v$rollstat vWhere r.segment_id = v.usn(+order by segment_name;4、查看控制文件select name from v$controlfile;5、查看日志文件sel

16、ect member from v$logfile;6、查看表空間的使用情況select sum(bytes/(1024*1024 as free_space,tablespace_namefrom dba_free_spacegroup by tablespace_name;SELECT A.TABLESPACE_NAME,A.BYTES TOTAL,B.BYTES USED, C.BYTES FREE,(B.BYTES*100/A.BYTES "% USED",(C.BYTES*100/A.BYTES "% FREE"FROM SYS.SM$TS_A

17、VAIL A,SYS.SM$TS_USED B,SYS.SM$TS_FREE CWHERE A.TABLESPACE_NAME=B.TABLESPACE_NAME AND A.TABLESPACE_NAME=C.TABLESPACE_NAME;7、查看數(shù)據(jù)庫(kù)庫(kù)對(duì)象select owner, object_type, status, count(* count# from all_objects group by owner, object_type, status;8、查看數(shù)據(jù)庫(kù)的版本Select version FROM Product_component_versionWhere SUBS

18、TR(PRODUCT,1,6='Oracle'9、查看數(shù)據(jù)庫(kù)的創(chuàng)建日期和歸檔方式Select Created, Log_Mode, Log_Mode From V$Database;10、捕捉運(yùn)行很久的SQLcolumn username format a12column opname format a16column progress format a8select username,sid,opname,round(sofar*100 / totalwork,0 | '%' as progress,time_remaining,sql_textfrom v$

19、session_longops , v$sqlwhere time_remaining <> 0and sql_address = addressand sql_hash_value = hash_value11。查看數(shù)據(jù)表的參數(shù)信息SELECT partition_name, high_value, high_value_length, tablespace_name, pct_free, pct_used, ini_trans, max_trans, initial_extent,next_extent, min_extent, max_extent, pct_increase

20、, FREELISTS,freelist_groups, LOGGING, BUFFER_POOL, num_rows, blocks,empty_blocks, avg_space, chain_cnt, avg_row_len, sample_size,last_analyzedFROM dba_tab_partitions-WHERE table_name = :tname AND table_owner = :townerORDER BY partition_position12.查看還沒(méi)提交的事務(wù)select * from v$locked_object;select * from

21、v$transaction;13。查找object為哪些進(jìn)程所用selectp.spid,s.sid,s.serial# serial_num,s.username user_name,a.type object_type,s.osuser os_user_name,a.owner,a.object object_name,decode(sign(48 - command,1,to_char(command, 'Action Code #' | to_char(command action,gram oracle_process,s.terminal terminal

22、,gram program,s.status session_statusfrom v$session s, v$access a, v$process pwhere s.paddr = p.addr ands.type = 'USER' anda.sid = s.sid anda.object='SUBSCRIBER_ATTR'order by s.username, s.osuser14?;貪L段查看Extents, v$rollstat.rssize Size_in_Bytes, v$rollstat.xacts XActs,v$rollstat.

23、gets Gets, v$rollstat.waits Waits, v$rollstat.writes Writes,v$rollstat.usn (+ = v$rollname.usn order by rownum15。耗資源的進(jìn)程(top sessionselect s.schemaname schema_name, decode(sign(48 - command, 1,to_char(command, 'Action Code #' | to_char(command action, statussession_status, s.osuser os_user_na

24、me, s.sid, p.spid , s.serial# serial_num,nvl(s.username, 'Oracle process' user_name, s.terminal terminal,gram program, st.value criteria_value from v$sesstat st, v$session s ,v$process pwhere st.sid = s.sid and st.statistic# = to_number('38' and ('ALL' = 'ALL'or

25、s.status = 'ALL' and p.addr = s.paddr order by st.value desc, p.spid asc,s.username asc, s.osuser asc16。查看鎖(lock情況select /*+ RULE */ ls.osuser os_user_name, ls.username user_name,decode(ls.type, 'RW', 'Row wait enqueue lock', 'TM', 'DML enqueue lock', 'TX&

26、#39;,'Transaction enqueue lock', 'UL', 'User supplied lock' lock_type,o.object_name object, decode(ls.lmode, 1, null, 2, 'Row Share', 3,'Row Exclusive', 4, 'Share', 5, 'Share Row Exclusive', 6, 'Exclusive', nulllock_mode, o.owner, ls.si

27、d, ls.serial# serial_num, ls.id1, ls.id2from sys.dba_objects o, ( select s.osuser, s.username, l.type,l.lmode, s.sid, s.serial#, l.id1, l.id2 from v$session s,v$lock l where s.sid = l.sid ls where o.object_id = ls.id1 and o.owner<> 'SYS' order by o.owner, o.object_name17。查看等待(wait情況SEL

28、ECT v$waitstat.class, v$waitstat.count count, SUM(v$sysstat.value sum_valueFROM v$waitstat, v$sysstat WHERE v$ IN ('db block gets','consistent gets' group by v$waitstat.class, v$waitstat.count18。查看sga情況SELECT NAME, BYTES FROM SYS.V_$SGASTAT ORDER BY NAME ASC19。查看catched o

29、bjectSELECT owner, name, db_link, namespace,type, sharable_mem, loads, executions,locks, pins, kept FROMv$db_object_cache20。查看V$SQLAREASELECT SQL_TEXT, SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM, SORTS,VERSION_COUNT, LOADED_VERSIONS, OPEN_VERSIONS, USERS_OPENING, EXECUTIONS,USERS_EXECUTING, LOADS, FI

30、RST_LOAD_TIME, INVALIDATIONS, PARSE_CALLS, DISK_READS,BUFFER_GETS, ROWS_PROCESSED FROM V$SQLAREA21。查看object分類數(shù)量select decode (o.type#,1,'INDEX' , 2,'TABLE' , 3 , 'CLUSTER' , 4, 'VIEW' , 5 ,'SYNONYM' , 6 , 'SEQUENCE' , 'OTHER' object_type , coun

31、t(* quantity fromsys.obj$ o where o.type# > 1 group by decode (o.type#,1,'INDEX' , 2,'TABLE' , 3, 'CLUSTER' , 4, 'VIEW' , 5 , 'SYNONYM' , 6 , 'SEQUENCE' , 'OTHER' union select'COLUMN' , count(* from sys.col$ union select 'DB LINK

32、' , count(* from22。按用戶查看object種類select schema, sum(decode(o.type#, 1, 1, NULL indexes,sum(decode(o.type#, 2, 1, NULL tables, sum(decode(o.type#, 3, 1, NULLclusters, sum(decode(o.type#, 4, 1, NULL views, sum(decode(o.type#, 5, 1,NULL synonyms, sum(decode(o.type#, 6, 1, NULL sequences,sum(d

33、ecode(o.type#, 1, NULL, 2, NULL, 3, NULL, 4, NULL, 5, NULL, 6, NULL, 1others from sys.obj$ o, sys.user$ u where o.type# >= 1 and u.user# =o.owner# and <> 'PUBLIC' group by order bysys.link$ union select 'CONSTRAINT' , count(* from sys.con$23。有關(guān)connection的相關(guān)信息1查

34、看有哪些用戶連接select s.osuser os_user_name, decode(sign(48 - command, 1, to_char(command, 'Action Code #' | to_char(command action, gram oracle_process, status session_status, s.terminal terminal, gram program,s.username user_name, s.fixed_table_sequence activity_meter, '' query,

35、 0 memory, 0 max_memory, 0 cpu_usage, s.sid, s.serial# serial_num from v$session s, v$process p where s.paddr=p.addr and s.type = 'USER' order by s.username, s.osuser2根據(jù)v.sid查看對(duì)應(yīng)連接的資源占用等情況select ,v.value,n.class,n.statistic#from v$statname n,v$sesstat vwhere v.sid = 71 andv.statistic#

36、= n.statistic#order by n.class, n.statistic#3根據(jù)sid查看對(duì)應(yīng)連接正在運(yùn)行的sqlselect /*+ PUSH_SUBQ */command_type,sql_text,sharable_mem,persistent_mem,runtime_mem,sorts,version_count,loaded_versions,open_versions,users_opening,executions,users_executing,loads,first_load_time,invalidations,parse_calls,disk_reads,b

37、uffer_gets,rows_processed,sysdate start_time,sysdate finish_time,'>' | address sql_address,'N' statusfrom v$sqlareawhere address = (select sql_address from v$session where sid = 712根據(jù)v.sid查看對(duì)應(yīng)連接的資源占用等情況select ,v.value,n.class,n.statistic#from v$statname n,v$sesstat vwhere v.

38、sid = 71 andv.statistic# = n.statistic#order by n.class, n.statistic#3根據(jù)sid查看對(duì)應(yīng)連接正在運(yùn)行的sqlselect /*+ PUSH_SUBQ */command_type,sql_text,sharable_mem,persistent_mem,runtime_mem,sorts,version_count,loaded_versions,open_versions,users_opening,executions,users_executing,loads,first_load_time,invalidations

39、,parse_calls,disk_reads,buffer_gets,rows_processed,sysdate start_time,sysdate finish_time,'>' | address sql_address,'N' statusfrom v$sqlareawhere address = (select sql_address from v$session where sid = 7124查詢表空間使用情況 select a.tablespace_name "表空間名稱", 100-round(nvl(b.byte

40、s_free,0/a.bytes_alloc*100,2 "占用率(%", round(a.bytes_alloc/1024/1024,2 "容量(M", round(nvl(b.bytes_free,0/1024/1024,2 "空閑(M", round(a.bytes_alloc-nvl(b.bytes_free,0/1024/1024,2 "使用(M", Largest "最大擴(kuò)展段(M", to_char(sysdate,'yyyy-mm-dd hh24:mi:ss' "采樣時(shí)間" from (select f.tablespace_name, sum(f.bytes bytes

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論