推荐下载Oracle系统表大全 精品.docx
《推荐下载Oracle系统表大全 精品.docx》由会员分享,可在线阅读,更多相关《推荐下载Oracle系统表大全 精品.docx(8页珍藏版)》请在冰点文库上搜索。
![推荐下载Oracle系统表大全 精品.docx](https://file1.bingdoc.com/fileroot1/2023-6/16/ac261ea5-6c7d-4a65-ad8b-57f0815f87cb/ac261ea5-6c7d-4a65-ad8b-57f0815f87cb1.gif)
推荐下载Oracle系统表大全精品
数据字典dict总是属于Oracle用户sys的。
1、用户:
selectusernamefromdba_users;
改口令
alteruserspgroupidentifiedbyspgtest;
2、表空间:
select*fromdba_data_files;
select*fromdba_tablespaces;//表空间
selecttablespace_name,sum(bytes),sum(blocks)
fromdba_free_spacegroupbytablespace_name;//空闲表空间
select*fromdba_data_files
wheretablespace_name='RBS';//表空间对应的数据文件
select*fromdba_segments
wheretablespace_name='INDEXS';
3、数据库对象:
select*fromdba_objects;
CLUSTER、DATABASELINK、FUNCTION、INDEX、LIBRARY、PACKAGE、PACKAGEBODY、
PROCEDURE、SEQUENCE、SYNONYM、TABLE、TRIGGER、TYPE、UNDEFINED、VIEW。
4、表:
select*fromdba_tables;
analyzemy_tableputestatistics;->dba_tables后6列
selectextent_id,bytesfromdba_extents
wheresegment_name='CUSTOMERS'andsegment_type='TABLE'
orderbyextent_id;//表使用的extent的信息。
segment_type='ROLLBACK'查看回滚段的空间分配信息
列信息:
selectdistincttable_name
fromuser_tab_columns
wherecolumn_name='SO_TYPE_ID';
5、索引:
select*fromdba_indexes;//索引,包括主键索引
select*fromdba_ind_columns;//索引列
selecti.index_name,i.uniqueness,c.column_name
fromuser_indexesi,user_ind_columnsc
wherei.index_name=c.index_name
andi.table_name='ACC_NBR';//联接使用
6、序列:
select*fromdba_sequences;
7、视图:
select*fromdba_views;
select*fromall_views;
text可用于查询视图生成的脚本
8、聚簇:
select*fromdba_clusters;
9、快照:
select*fromdba_snapshots;
快照、分区应存在相应的表空间。
10、同义词:
select*fromdba_synonyms
wheretable_owner='SPGROUP';
//ifownerisPUBLIC,thenthesynonymsisapublicsynonym.
ifownerisoneofusers,thenthesynonymsisaprivatesynonym.
11、数据库链:
select*fromdba_db_links;
在spbase下建数据库链
createdatabaselinkdbl_spnew
connecttospnewidentifiedbyspnewusing'jhhx';
insertintoacc_nbr@dbl_spnew
select*fromacc_nbrwherenxx_nbr='237'andline_nbr='8888';
12、触发器:
select*fromdba_trigers;
存储过程,函数从dba_objects查找。
其文本:
selecttextfromuser_sourcewherename='BOOK_SP_EXAMPLE';
建立出错:
select*fromuser_errors;
oracle总是将存储过程,函数等软件放在SYSTEM表空间。
13、约束:
(1)约束是和表关联的,可在createtable或altertabletable_nameadd/drop/modify来建立、修改、删除约束。
可以临时禁止约束,如:
altertablebook_example
disableconstraintbook_example_1;
altertablebook_example
enableconstraintbook_example_1;
(2)主键和外键被称为表约束,而notnull和unique之类的约束被称为列约束。
通常将主键和外键作为单独的命名约束放在字段列表下面,而列约束可放在列定义的同一行,这样更具有可读性。
(3)列约束可从表定义看出,即describe;表约束即主键和外键,可从dba_constraints和dba_cons_columns查。
select*fromuser_constraints
wheretable_name='BOOK_EXAMPLE';
selectowner,CONSTRAINT_NAME,TABLE_NAME
fromuser_constraints
whereconstraint_type='R'
orderbytable_name;
(4)定义约束可以无名(系统自动生成约束名)和自己定义约束名(特别是主键、外键)
如:
createtablebook_example
(identifiernumbernotnull);
createtablebook_example
(identifiernumberconstranitbook_example_1notnull);
14、回滚段:
在所有的修改结果存入磁盘前,回滚段中保持恢复该事务所需的全部信息,必须以数据库发生的事务来相应确定其大小(DML语句才可回滚,create,drop,truncate等DDL不能回滚)。
回滚段数量=并发事务/4,但不能超过50;使每个回滚段大小足够处理一个完整的事务;
createrollbacksegmentr05
tablespacerbs;
createrollbacksegmentrbs_cvt
tablespacerbs
storage(initial1Mnext500k);
使回滚段在线
alterrollbacksegmentr04online;
用dba_extents,v$rollback_segs监测回滚段的大小和动态增长。
回滚段的区间信息
select*fromdba_extents
wheresegment_type='ROLLBACK'andsegment_name='RB1';
回滚段的段信息,其中bytes显示目前回滚段的字节数
select*fromdba_segments
wheresegment_type='ROLLBACK'andsegment_name='RB1';
为事物指定回归段
settransactionuserollbacksegmentrbs_cvt
针对bytes可以使用回滚段回缩。
alterrollbacksegmentrbs_cvtshrink;
selectbytes,extents,max_extentsfromdba_segments
wheresegment_type='ROLLBACK'andsegment_name='RBS_CVT';
回滚段的当前状态信息:
select*fromdba_rollback_segs
wheresegment_name='RB1';
比多回滚段状态status,回滚段所属实例instance_num
查优化值optimal
selectn.name,s.optsize
fromv$rollnamen,v$rollstats
wheren.usn=s.usn;
回滚段中的数据
settransactionuserollbacksegmentrb1;/*回滚段名*/
selectn.name,s.writes
fromv$rollnamen,v$rollstats
wheren.usn=s.usn;
当事务处理完毕,再次查询$rollstat,比较writes(回滚段条目字节数)差值,可确定事务的大小。
查询回滚段中的事务
columnrrheading'RBSegment'formata18
columnusheading'Username'formata15
columnosheading'OsUser'formata10
columnteheading'Terminal'formata10
selectr.namerr,nvl(s.username,'notransaction')us,s.osuseros,s.terminalte
fromv$lockl,v$sessions,v$rollnamer
wherel.sid=s.sid(+)
andtrunc(l.id1/65536)=R.USN
andl.type='TX'
andl.lmode=6
orderbyr.name;
15、作业
查询作业信息
selectjob,broken,next_date,interval,whatfromuser_jobs;
selectjob,broken,next_date,interval,whatfromdba_jobs;
查询正在运行的作业
select*fromdba_jobs_running;
使用包execdbms_job.submit(:
v_num,'a;',sysdate,'sysdate+(10/(24*60*60))')加入作业。
间隔10秒钟
execdbms_job.submit(:
v_num,'a;',sysdate,'sysdate+(11/(24*60))')加入作业。
间隔11分钟使用包execdbms_job.remove(21)删除21号作业。
............
............
Postedbypuppyin[玩吧]at20XX-11-0610:
10:
03|访问891次|续文:
4
[返回上一页]
↓该Blog续文信息↓
1.查询oracle表空间的使用情况
selectb.file_id 文件ID,
b.tablespace_name 表空间,
b.file_name 物理文件名,
b.bytes 总字节数,
(b.bytes-sum(nvl(a.bytes,0))) 已使用,
sum(nvl(a.bytes,0)) 剩余,
sum(nvl(a.bytes,0))/(b.bytes)*100 剩余百分比
fromdba_free_spacea,dba_data_filesb
wherea.file_id=b.file_id
groupbyb.tablespace_name,b.file_name,b.file_id,b.bytes
orderbyb.tablespace_name
2.查询oracle系统用户的默认表空间和临时表空间
selectdefault_tablespace,temporary_tablespacefromdba_users
3.查询单张表的使用情况
selectsegment_name,bytesfromdba_segmentswheresegment_name='RE_STDEVT_FACT_DAY'andowner=USER
RE_STDEVT_FACT_DAY是您要查询的表名称
4.查询所有用户表使用大小的前三十名
select*from(selectsegment_name,bytesfromdba_segmentswhereowner=USERorderbybytesdesc)whererownum<=30
5.查询当前用户默认表空间的使用情况
selecttablespacename,sum(totalContent),sum(usecontent),sum(sparecontent),avg(sparepercent)
from
(
SELECTb.file_idasid,b.tablespace_nameastablespacename,b.bytesastotalContent,(b.bytes-sum(nvl(a.bytes,0)))asusecontent,sum(nvl(a.bytes,0))assparecontent,sum(nvl(a.bytes,0))/(b.bytes)*100 assparepercent
FROMdba_free_spacea,dba_data_filesb
WHEREa.file_id=b.file_idandb.tablespace_name=(selectdefault_tablespacefromdba_userswhereusername=user)
groupbyb.tablespace_name,b.file_name,b.file_id,b.bytes
)
GROUPBYtablespacename
6.查询用户表空间的表
select * fromuser_tables
Postedbypuppyat20XX-11-0611:
09:
07
select*from(
selectbytes,segment_name,segment_type,ownerfromdba_segments
wheretablespace_name='SYSTEM'
orderbybytesdesc
)whererownum<10
Postedbypuppyat20XX-11-0719:
44:
33
SQL>selecttablespace_name,(bytes/1024/1024)Mfromdba_data_files;
TABLESPACE_NAME M
----------------------------------------------------------------------
USERS 5
SYSAUX 310
UNDOTBS1 30
SYSTEM 490
EXAMPLE 100
Postedbypuppyat20XX-11-0719:
45:
16
system表空间增大是正常的,但急剧增大是不合理的。
1有可能是用户对象错误的放在系统表空间中
2也可能是system表空间的UNDO过大
3还有可能和高级复制的空间使用有关
可通过如下语句查看一下是不是有应用的段放到了SYSTEM中:
selectOWNER,SEGMENT_NAME,SEGMENT_TYPE,BYTESfromDBA_SEGMENTSwhereTABLESPACE_NAME='SYSTEM'andOWNERnotin('SYS','SYSTEM')
通过如下查询语句查看找出系统表空间中占用空间最多的Top9对象
SELECT*
FROM(SELECTBYTES,segment_name,segment_type,owner
FROMdba_segments
WHEREtablespace_name='SYSTEM'
ORDERBYBYTESDESC)
WHEREROWNUM<10
高级复制会使用sys.IDL_UB1$
摘自,DatabaseAdministrator’sGuide第70页
IfyouuseAdvancedReplicationandintendtosetupalargenumberofreplicated
objects,thenyouarerequiredtomonitorthefollowingdatadictionarytableswith
theSQLSELECTmand:
nARGUMENT$
nIDL_CHAR$
nIDL_UB1$
nIDL_UB2$
nIDL_SB4$
nI_ARGUMENT1
nI_SOURCE1I$
nSOURCE$
nTRIGGER
Ifnecessary,increasestorageparameterstoacmodatestoragerequirementsof
largenumbersofreplicatedobjects.
请参考eygle的文章(http:
//.eygle./archives/20XX/01/idl_ub1_table.html)
系统对象IDL_UB1$表的含义及作用
在ITPUB上有朋友遇到SYSTEM表空间快速扩展的问题
系统表空间异常扩展的情况遇到过很多:
有的和用户表空间或对象分配不当有关
有的和高级复制的空间使用有关....
经过如下代码查询,可以找出系统表空间中占用空间最多的Top9对象:
colsegment_namefora25
colownerfora10
SELECT*
FROM(SELECT BYTES,segment_name,segment_type,owner
FROMdba_segments
WHEREtablespace_name='SYSTEM'
ORDERBYBYTESDESC)
WHEREROWNUM<10
/
这个朋友的Top9对象为:
1 3082174464 IDL_UB1$TABLESYS
2 63979520 SOURCE$TABLESYS
3 12075008 IDL_UB2$TABLESYS
4 7749632 DEPENDENCY$TABLESYS
5 7356416 I_DEPENDENCY2INDEXSYS
6 6438912 I_DEPENDENCY1INDEXSYS
7 5521408 I_IDL_UB11 INDEXSYS
8 4341760 IDL_SB4$TABLESYS
9 3555328 I_ACCESS1 INDEXSYS
我们注意到占用空间最大的对象是IDL_UB1$系统表,空间占用近3G,那么这个表是做什么用的呢?
从sql.bsq中我们可以找到这个表的创建语句:
createtableidl_ub1$ /*idltableforub1pieces*/
(obj# numbernotnull, /*objectnumber*/
part numbernotnull,
/*part:
0=diana,1=portablepcode,2=machine-dependentpcode*/
version number, /*versionnumber*/
piece# numbernotnull, /*piecenumber*/
length numbernotnull, /*piecelength*/
piece longrawnotnull) /*ub1piece*/
storage(initial10knext100kmaxextentsunl