![Oracle常用數(shù)據(jù)字典表及動態(tài)視圖_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/5/5ff21b54-e0c2-4654-89d9-4b79d0af5479/5ff21b54-e0c2-4654-89d9-4b79d0af54791.gif)
![Oracle常用數(shù)據(jù)字典表及動態(tài)視圖_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/5/5ff21b54-e0c2-4654-89d9-4b79d0af5479/5ff21b54-e0c2-4654-89d9-4b79d0af54792.gif)
![Oracle常用數(shù)據(jù)字典表及動態(tài)視圖_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/5/5ff21b54-e0c2-4654-89d9-4b79d0af5479/5ff21b54-e0c2-4654-89d9-4b79d0af54793.gif)
![Oracle常用數(shù)據(jù)字典表及動態(tài)視圖_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/5/5ff21b54-e0c2-4654-89d9-4b79d0af5479/5ff21b54-e0c2-4654-89d9-4b79d0af54794.gif)
![Oracle常用數(shù)據(jù)字典表及動態(tài)視圖_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-2/5/5ff21b54-e0c2-4654-89d9-4b79d0af5479/5ff21b54-e0c2-4654-89d9-4b79d0af54795.gif)
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、Oracle常用數(shù)據(jù)字典表 查看當前用戶的缺省表空間SQL>select username,default_tablespace from user_users; 查看當前用戶的角色SQL>select * from user_role_privs;查看當前用戶的系統(tǒng)權限和表級權限SQL>select * from user_sys_privs;SQL>select * from user_tab_privs;查看用戶下所有的表SQL>select * from user_tables;查看用戶下所有的表的列屬性SQL>select * from USER_
2、TAB_COLUMNS where table_name=:table_Name;顯示用戶信息(所屬表空間select default_tablespace,temporary_tablespace from dba_users where username='GAME'1、用戶查看當前用戶的缺省表空間SQL>select username,default_tablespace from user_users;查看當前用戶的角色SQL>select * from user_role_privs;查看當前用戶的系統(tǒng)權限和表級權限SQL>select * from
3、 user_sys_privs;SQL>select * from user_tab_privs;顯示當前會話所具有的權限SQL>select * from session_privs;顯示指定用戶所具有的系統(tǒng)權限SQL>select * from dba_sys_privs where grantee='GAME'顯示特權用戶select * from v$pwfile_users;顯示用戶信息(所屬表空間select default_tablespace,temporary_tablespace from 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)建時間SQL>select object_name,created from user_objects
5、where object_name=upper('&table_name'查看某表的大小SQL>select sum(bytes/(1024*1024 as "size(M" from user_segmentswhere segment_name=upper('&table_name'查看放在Oracle的內存區(qū)里的表SQL>select table_name,cache from user_tables where instr(cache,'Y'>0;3、索引查看索引個數(shù)和類別SQL>
6、;select 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_na
7、me'4、序列號查看序列號,last_number是當前值SQL>select * from user_sequences;5、視圖查看視圖的名稱SQL>select view_name from user_views;查看創(chuàng)建視圖的select語句SQL>set view_name,text_length from user_views;SQL>set long 2000; 說明:可以根據(jù)視圖的text_length值設定set long 的大小SQL>select text from user_views where view_name=upper(&
8、#39;&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_
9、namefrom 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、存儲函數(shù)和過程查看函數(shù)和過程的狀態(tài)SQL>select object_name,status from user_objec
10、ts where object_type='FUNCTION'SQL>select object_name,status from user_objects where object_type='PROCEDURE'查看函數(shù)和過程的源代碼SQL>select text from all_source where owner=user and name=upper('&plsql_name'常用的數(shù)據(jù)字典:dba_data_files:通常用來查詢關于數(shù)據(jù)庫文件的信息dba_db_links:包括數(shù)據(jù)庫中的所有數(shù)據(jù)庫鏈路,也就是
11、databaselinks。dba_extents:數(shù)據(jù)庫中所有分區(qū)的信息dba_free_space:所有表空間中的自由分區(qū)dba_indexs:關于數(shù)據(jù)庫中所有索引的描述dba_ind_columns:在所有表及聚集上壓縮索引的列dba_objects:數(shù)據(jù)庫中所有的對象dba_rollback_segs:回滾段的描述dba_segments:所有數(shù)據(jù)庫段分段的存儲空間dba_synonyms:關于同義詞的信息查詢dba_tables:數(shù)據(jù)庫中所有數(shù)據(jù)表的描述dba_tabespaces:關于表空間的信息dba_tab_columns:所有表描述、視圖以及聚集的列dba_tab_grant
12、s/privs:對象所授予的權限dba_ts_quotas:所有用戶表空間限額dba_users:關于數(shù)據(jù)的所有用戶的信息dba_views:數(shù)據(jù)庫中所有視圖的文本常用的動態(tài)性能視圖:v$datafile:數(shù)據(jù)庫使用的數(shù)據(jù)文件信息v$librarycache:共享池中SQL語句的管理信息v$lock:通過訪問數(shù)據(jù)庫會話,設置對象鎖的所有信息v$log:從控制文件中提取有關重做日志組的信息v$logfile有關實例重置日志組文件名及其位置的信息v$parameter:初始化參數(shù)文件中所有項的值v$process:當前進程的信息v$rollname:回滾段信息v$rollstat:聯(lián)機回滾段統(tǒng)計信
13、息v$rowcache:內存中數(shù)據(jù)字典活動/性能信息v$session:有關會話的信息v$sesstat:在v$session中報告當前會話的統(tǒng)計信息v$sqlarea:共享池中使用當前光標的統(tǒng)計信息,光標是一塊內存區(qū)域,有Oracle處理SQL語句時打開。v$statname:在v$sesstat中報告各個統(tǒng)計的含義v$sysstat:基于當前操作會話進行的系統(tǒng)統(tǒng)計v$waitstat:出現(xiàn)一個以上會話訪問數(shù)據(jù)庫的數(shù)據(jù)時的詳細情況。當有一個以上的會話訪問同一信息時,可出現(xiàn)等待情況??偨Y了一下這些,徹底區(qū)別了視圖與數(shù)據(jù)字典,也不那么容易混淆。嘿嘿!常用SQL查詢:1、查看表空間的名稱及大小se
14、lect 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 tables
15、pace_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、查看日志文
16、件select member from v$logfile;6、查看表空間的使用情況select sum(bytes/(1024*1024 as free_space,tablespace_name from 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
17、$TS_AVAIL 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ù)庫庫對象select owner, object_type, status, count(* count# from all_objects group by owner, object_type, status;8、查看數(shù)據(jù)庫的版本Select version FROM Product_component_version Whe
18、re SUBSTR(PRODUCT,1,6='Oracle'9、查看數(shù)據(jù)庫的創(chuàng)建日期和歸檔方式Select Created, Log_Mode, Log_Mode From V$Database; 10、捕捉運行很久的SQLcolumn username format a12 column opname format a16 column progress format a8 select username,sid,opname, round(sofar*100 / totalwork,0 | '%' as progress, time_remaining,sq
19、l_text from v$session_longops , v$sql where time_remaining <> 0 and sql_address = address and sql_hash_value = hash_value 11。查看數(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_ext
20、ent, pct_increase, 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.查看還沒提交的事務select * from v$locked_obje
21、ct;select * from v$transaction;13。查找object為哪些進程所用select p.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
22、.terminal terminal,gram program,s.status session_status from v$session s, v$access a, v$process p where s.paddr = p.addr ands.type = 'USER' and a.sid = s.sid anda.object='SUBSCRIBER_ATTR'order by s.username, s.osuser14。回滾段查看select rownum, sys.dba_rollback_segs.segment_name Name,
23、 v$rollstat.extents Extents, v$rollstat.rssize Size_in_Bytes, v$rollstat.xacts XActs, v$rollstat.gets Gets, v$rollstat.waits Waits, v$rollstat.writes Writes, sys.dba_rollback_segs.status status from v$rollstat, sys.dba_rollback_segs, v$rollname where v$(+ = sys.dba_rollback_segs.segment
24、_name and v$rollstat.usn (+ = v$rollname.usn order by rownum15。耗資源的進程(top session)select s.schemaname schema_name, decode(sign(48 - command, 1, to_char(command, 'Action Code #' | to_char(command action, status session_status, s.osuser os_user_name, s.sid, p.spid , s.serial# serial_num, nvl(s
25、.username, 'Oracle process' user_name, s.terminal terminal, gram program, st.value criteria_value from v$sesstat st, v$session s , v$process p where st.sid = s.sid and st.statistic# = to_number('38' and ('ALL' = 'ALL' or s.status = 'ALL' and p.addr = s.pa
26、ddr 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', 'Transaction enqueue lock'
27、;, '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', null lock_mode, o.owner, ls.sid, ls.serial# serial_num, ls.id1, l
28、s.id2 from 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)情況SELECT v$waitstat.class, v$waitst
29、at.count count, SUM(v$sysstat.value sum_value FROM 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 objectSELECT owner, name, db_
30、link, namespace, type, sharable_mem, loads, executions, locks, pins, kept FROM v$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, FIRST_LOAD_TIME, INVALIDA
31、TIONS, 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 , count(* quantity from sys.
32、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' , count(* fro
33、m 22。按用戶查看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, NULL clusters, 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(decode(o.type#,
34、 1, NULL, 2, NULL, 3, NULL, 4, NULL, 5, NULL, 6, NULL, 1 others from sys.obj$ o, sys.user$ u where o.type# >= 1 and u.user# = o.owner# and <> 'PUBLIC' group by order by sys.link$ union select 'CONSTRAINT' , count(* from sys.con$23。有關connection的相關信息1)查看有哪些用戶連接se
35、lect 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, 0 memory,
36、 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查看對應連接的資源占用等情況select , v.value, n.class,n.statistic# from v$statname n, v$sesstat v where v.sid = 71 and v.statistic# = n
37、.statistic# order by n.class, n.statistic#3)根據(jù)sid查看對應連接正在運行的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_call
38、s, disk_reads, buffer_gets, rows_processed,sysdate start_time,sysdate finish_time,'>' | address sql_address,'N' status from v$sqlareawhere address = (select sql_address from v$session where sid = 712)根據(jù)v.sid查看對應連接的資源占用等情況select , v.value, n.class,n.statistic# from v$statname
39、 n, v$sesstat v where v.sid = 71 and v.statistic# = n.statistic# order by n.class, n.statistic#3)根據(jù)sid查看對應連接正在運行的sqlselect /*+ PUSH_SUBQ */command_type, sql_text, sharable_mem, persistent_mem, runtime_mem, sorts, version_count, loaded_versions, open_versions, users_opening, executions, users_executi
40、ng, loads, first_load_time, invalidations, parse_calls, disk_reads, buffer_gets, rows_processed,sysdate start_time,sysdate finish_time,'>' | address sql_address,'N' status from v$sqlareawhere address = (select sql_address from v$session where sid = 7124查詢表空間使用情況select a.tablespace
41、_name "表空間名稱",100-round(nvl(b.bytes_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 "最大擴展段(M",to_char(sysdate,'yyyy-mm-dd hh24:mi:ss' "采樣時間" f
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 3920-2024紡織品色牢度試驗耐摩擦色牢度
- 2023-2024學年高一秋學期期末語文模擬測試(二)試題
- 年會領導講話稿(集合15篇)
- 小學生處處防患時時安全
- 第三單元+全面依法治國+練習(B卷) 高中政治統(tǒng)編版必修三政治與法治
- 心理健康教育活動總結
- 初級會計實務-初級會計《初級會計實務》模擬試卷277
- 智研咨詢-2024年中國半導體激光器行業(yè)市場全景調查、投資策略研究報告
- 基于動態(tài)物體先驗的物體級SLAM算法研究
- 基于SCR結構的抗閂鎖ESD保護器件優(yōu)化設計
- 2024年全國職業(yè)院校技能大賽高職組(研學旅行賽項)考試題庫(含答案)
- 電器儀表人員培訓課件
- 2025年中小學春節(jié)安全教育主題班會課件
- (人衛(wèi)版第九版?zhèn)魅静W總論(一))課件
- 粉條加工廠建設項目可行性研究報告
- 食品企業(yè)日管控周排查月調度記錄及其報告格式參考
- 產品質量法解讀課件1
- 倉庫搬遷及改進方案課件
- 煤礦機電運輸培訓課件
- 畢業(yè)論文-山東省農產品出口貿易的現(xiàn)狀及對策研究
- 音樂思政課特色課程設計
評論
0/150
提交評論