Oracle系统表大全Word文档格式.docx
《Oracle系统表大全Word文档格式.docx》由会员分享,可在线阅读,更多相关《Oracle系统表大全Word文档格式.docx(11页珍藏版)》请在冰豆网上搜索。
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;
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='
andsegment_name='
RB1'
回滚段的段信息,其中bytes显示目前回滚段的字节数
wheresegment_type='
为事物指定回归段
settransactionuserollbacksegmentrbs_cvt
针对bytes可以使用回滚段回缩。
alterrollbacksegmentrbs_cvtshrink;
selectbytes,extents,max_extentsfromdba_segments
RBS_CVT'
回滚段的当前状态信息:
select*fromdba_rollback_segs
wheresegment_name='
比多回滚段状态status,回滚段所属实例instance_num
查优化值optimal
selectn.name,s.optsize
fromv$rollnamen,v$rollstats
wheren.usn=s.usn;
回滚段中的数据
settransactionuserollbacksegmentrb1;
/*回滚段名*/
selectn.name,s.writes
当事务处理完毕,再次查询$rollstat,比较writes(回滚段条目字节数)差值,可确定事务的大小。
查询回滚段中的事务
columnrrheading'
RBSegment'
formata18
columnusheading'
Username'
formata15
columnosheading'
OsUser'
formata10
columnteheading'
Terminal'
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(:
sysdate+(11/(24*60))'
间隔11分钟使用包execdbms_job.remove(21)删除21号作业。
............
Postedbypuppyin[玩吧]at2008-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)*100assparepercent
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
Postedbypuppyat2008-11-0611:
09:
07
select*from(
selectbytes,segment_name,segment_type,ownerfromdba_segments
wheretablespace_name='
SYSTEM'
orderbybytesdesc
)whererownum<
10
Postedbypuppyat2008-11-0719:
44:
33
SQL>
selecttablespace_name,(bytes/1024/1024)Mfromdba_data_files;
TABLESPACE_NAMEM
----------------------------------------------------------------------
USERS5
SYSAUX310
UNDOTBS130
SYSTEM490
EXAMPLE100
45:
16
system表空间增大是正常的,但急剧增大是不合理的。
1有可能是用户对象错误的放在系统表空间中
2也可能是system表空间的UNDO过大
3还有可能和高级复制的空间使用有关
可通过如下语句查看一下是不是有应用的段放到了SYSTEM中:
selectOWNER,SEGMENT_NAME,SEGMENT_TYPE,BYTESfromDBA_SEGMENTSwhereTABLESPACE_NAME='
andOWNERnotin('
SYS'
'
通过如下查询语句查看找出系统表空间中占用空间最多的Top9对象
SELECT*
FROM(SELECTBYTES,segment_name,segment_type,owner
FROMdba_segments
WHEREtablespace_name='
ORDERBYBYTESDESC)
WHEREROWNUM<
高级复制会使用sys.IDL_UB1$
摘自,DatabaseAdministrator’sGuide第70页
IfyouuseAdvancedReplicationandintendtosetupalargenumberofreplicated
objects,thenyouarerequiredtomonitorthefollowingdatadictionarytableswith
theSQLSELECTcommand:
nARGUMENT$
nIDL_CHAR$
nIDL_UB1$
nIDL_UB2$
nIDL_SB4$
nI_ARGUMENT1
nI_SOURCE1I$
nSOURCE$
nTRIGGER
Ifnecessary,increasestorageparameterstoaccommodatestoragerequirementsof
largenumbersofreplicatedobjects.
请参考eygle的文章(
系统对象IDL_UB1$表的含义及作用
在ITPUB上有朋友遇到SYSTEM表空间快速扩展的问题
系统表空间异常扩展的情况遇到过很多:
有的和用户表空间或对象分配不当有关
有的和高级复制的空间使用有关....
经过如下代码查询,可以找出系统表空间中占用空间最多的Top9对象:
colsegment_namefora25
colownerfora10
/
这个朋友的Top9对象为:
13082174464IDL_UB1$TABLESYS
263979520SOURCE$TABLESYS
312075008IDL_UB2$TABLESYS
47749632DEPENDENCY$TABLESYS
57356416I_DEPENDENCY2INDEXSYS
66438912I_DEPENDENCY1INDEXSYS
75521408I_IDL_UB11INDEXSYS
84341760IDL_SB4$TABLESYS
93555328I_ACCESS1INDEXSYS
我们注意到占用空间最大的对象是IDL_UB1$系统表,空间占用近3G,那么这个表是做什么用的呢?
从sql.bsq中我们可以找到这个表的创建语句:
createtableidl_ub1$/*idltableforub1pieces*/
(obj#numbernotnull,/*objectnumber*/
partnumbernotnull,
/*part:
0=diana,1=portablepcode,2=machine-dependentpcode*/
versionnumber,/*versionnumber*/
piece#numbernotnull,/*piecenumber*/
lengthnumbernotnull,/*piecelength*/
piecelongrawnotnull)/*ub1piece*/
storage(initial10knext100kmaxextentsunlimitedpctincrease0)
idl_ub1$表是用来存储PL/SQL的代码单元的,包括DIANA等,IDL在这里代表InterfaceDefinitionLanguage.
这个对象的含义可以从Ixora找到一点提示:
ItisanintermediatelanguageinwhichthestructureofdatabasetablesandthelogicofPL/SQLprogramunitscanbeconsistentlyrepresentedasattributedtrees.OracleusestheDIANAIDL,whichcomesfromcompilersfortheAdaprogramminglanguage.DIANAstandsforDescriptiveIntermediateAttributedNotationforAda.Anyway,thisisoneoffourtablesinthedatadictionaryusedtostoretheDIANAforPL/SQLprogramunits,andthedatabaseobjectsthattheyreference.
在高级复制中会用到这个表,所以可能导致这个表快速增长,在Oracle10g之前,高级复制需要考虑的事情的确很多。