1、andsegment_type=TABLEorderbyextent_id;/表使用的extent的信息。segment_type=ROLLBACK查看回滚段的空间分配信息列信息:selectdistincttable_namefromuser_tab_columnswherecolumn_name=SO_TYPE_ID5、索引:select*fromdba_indexes;/索引,包括主键索引select*fromdba_ind_columns;/索引列selecti.index_name,i.uniqueness,c.column_namefromuser_indexesi,user_in
2、d_columnscwherei.index_name=c.index_nameandi.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_synonymswheretable_owner=SPGROUP/ifownerisP
3、UBLIC,thenthesynonymsisapublicsynonym.ifownerisoneofusers,thenthesynonymsisaprivatesynonym.11、数据库链:select*fromdba_db_links;在spbase下建数据库链createdatabaselinkdbl_spnewconnecttospnewidentifiedbyspnewusingjhhxinsertintoacc_nbrdbl_spnewselect*fromacc_nbrwherenxx_nbr=237andline_nbr=888812、触发器:select*fromdba
4、_trigers;存储过程,函数从dba_objects查找。其文本:selecttextfromuser_sourcewherename=BOOK_SP_EXAMPLE建立出错:select*fromuser_errors;oracle总是将存储过程,函数等软件放在SYSTEM表空间。13、约束:(1)约束是和表关联的,可在createtable或altertabletable_nameadd/drop/modify来建立、修改、删除约束。可以临时禁止约束,如:altertablebook_exampledisableconstraintbook_example_1;enableconstr
5、aintbook_example_1;(2)主键和外键被称为表约束,而notnull和unique之类的约束被称为列约束。通常将主键和外键作为单独的命名约束放在字段列表下面,而列约束可放在列定义的同一行,这样更具有可读性。(3)列约束可从表定义看出,即describe;表约束即主键和外键,可从dba_constraints和dba_cons_columns查。select*fromuser_constraintswheretable_name=BOOK_EXAMPLEselectowner,CONSTRAINT_NAME,TABLE_NAMEfromuser_constraintswherec
6、onstraint_type=Rorderbytable_name;(4)定义约束可以无名(系统自动生成约束名)和自己定义约束名(特别是主键、外键)如:createtablebook_example(identifiernumbernotnull);createtablebook_example(identifiernumberconstranitbook_example_1notnull);14、回滚段:在所有的修改结果存入磁盘前,回滚段中保持恢复该事务所需的全部信息,必须以数据库发生的事务来相应确定其大小(DML语句才可回滚,create,drop,truncate等DDL不能回滚)。回滚
7、段数量=并发事务/4,但不能超过50;使每个回滚段大小足够处理一个完整的事务;createrollbacksegmentr05tablespacerbs;createrollbacksegmentrbs_cvttablespacerbsstorage(initial1Mnext500k);使回滚段在线alterrollbacksegmentr04online;用dba_extents,v$rollback_segs监测回滚段的大小和动态增长。回滚段的区间信息select*fromdba_extentswheresegment_type=andsegment_name=RB1回滚段的段信息,其中
8、bytes显示目前回滚段的字节数wheresegment_type=为事物指定回归段settransactionuserollbacksegmentrbs_cvt针对bytes可以使用回滚段回缩。alterrollbacksegmentrbs_cvtshrink;selectbytes,extents,max_extentsfromdba_segmentsRBS_CVT回滚段的当前状态信息:select*fromdba_rollback_segswheresegment_name=比多回滚段状态status,回滚段所属实例instance_num查优化值optimalselectn.name,
9、s.optsizefromv$rollnamen,v$rollstatswheren.usn=s.usn;回滚段中的数据settransactionuserollbacksegmentrb1;/*回滚段名*/selectn.name,s.writes当事务处理完毕,再次查询$rollstat,比较writes(回滚段条目字节数)差值,可确定事务的大小。查询回滚段中的事务columnrrheadingRBSegmentformata18columnusheadingUsernameformata15columnosheadingOsUserformata10columnteheadingTerm
10、inalselectr.namerr,nvl(s.username,notransaction)us,s.osuseros,s.terminaltefromv$lockl,v$sessions,v$rollnamerwherel.sid=s.sid(+)andtrunc(l.id1/65536)=R.USNandl.type=TXandl.lmode=6orderbyr.name;15、作业查询作业信息selectjob,broken,next_date,interval,whatfromuser_jobs;selectjob,broken,next_date,interval,whatfro
11、mdba_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文件
12、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_filesbwherea.file_id=b.file_idgroupbyb.tablespace_name,b.file_name,b.file_id,b.bytesorderbyb.tablespace_name2.查询oracle系统用户的默认表空间和
13、临时表空间selectdefault_tablespace,temporary_tablespacefromdba_users3.查询单张表的使用情况selectsegment_name,bytesfromdba_segmentswheresegment_name=RE_STDEVT_FACT_DAYandowner=USERRE_STDEVT_FACT_DAY是您要查询的表名称4.查询所有用户表使用大小的前三十名select*from(selectsegment_name,bytesfromdba_segmentswhereowner=USERorderbybytesdesc)wherero
14、wnum=305.查询当前用户默认表空间的使用情况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)*10
15、0assparepercentFROMdba_free_spacea,dba_data_filesbWHEREa.file_id=b.file_idandb.tablespace_name=(selectdefault_tablespacefromdba_userswhereusername=user)groupbyb.tablespace_name,b.file_name,b.file_id,b.bytes)GROUPBYtablespacename6.查询用户表空间的表select*fromuser_tablesPostedbypuppyat2008-11-0611:09:07select
16、*from(selectbytes,segment_name,segment_type,ownerfromdba_segmentswheretablespace_name=SYSTEMorderbybytesdesc)whererownumselecttablespace_name,(bytes/1024/1024)Mfromdba_data_files;TABLESPACE_NAMEM-USERS5SYSAUX310UNDOTBS130SYSTEM490EXAMPLE10045:16system表空间增大是正常的,但急剧增大是不合理的。1有可能是用户对象错误的放在系统表空间中2也可能是sys
17、tem表空间的UNDO过大3还有可能和高级复制的空间使用有关可通过如下语句查看一下是不是有应用的段放到了SYSTEM中:selectOWNER,SEGMENT_NAME,SEGMENT_TYPE,BYTESfromDBA_SEGMENTSwhereTABLESPACE_NAME=andOWNERnotin(SYS,通过如下查询语句查看找出系统表空间中占用空间最多的Top9对象SELECT*FROM(SELECTBYTES,segment_name,segment_type,ownerFROMdba_segmentsWHEREtablespace_name=ORDERBYBYTESDESC)WH
18、EREROWNUM高级复制会使用sys.IDL_UB1$摘自,DatabaseAdministratorsGuide第70页IfyouuseAdvancedReplicationandintendtosetupalargenumberofreplicatedobjects,thenyouarerequiredtomonitorthefollowingdatadictionarytableswiththeSQLSELECTcommand:nARGUMENT$nIDL_CHAR$nIDL_UB1$nIDL_UB2$nIDL_SB4$nI_ARGUMENT1nI_SOURCE1I$nSOURCE$n
19、TRIGGERIfnecessary,increasestorageparameterstoaccommodatestoragerequirementsoflargenumbersofreplicatedobjects.请参考eygle的文章(系统对象IDL_UB1$表的含义及作用在ITPUB上有朋友遇到SYSTEM表空间快速扩展的问题系统表空间异常扩展的情况遇到过很多:有的和用户表空间或对象分配不当有关有的和高级复制的空间使用有关.经过如下代码查询,可以找出系统表空间中占用空间最多的Top9对象:colsegment_namefora25colownerfora10/这个朋友的Top9对象为
20、:13082174464IDL_UB1$TABLESYS263979520SOURCE$TABLESYS312075008IDL_UB2$TABLESYS47749632DEPENDENCY$TABLESYS57356416I_DEPENDENCY2INDEXSYS66438912I_DEPENDENCY1INDEXSYS75521408I_IDL_UB11INDEXSYS84341760IDL_SB4$TABLESYS93555328I_ACCESS1INDEXSYS我们注意到占用空间最大的对象是IDL_UB1$系统表,空间占用近3G,那么这个表是做什么用的呢?从sql.bsq中我们可以找到
21、这个表的创建语句:createtableidl_ub1$/*idltableforub1pieces*/(obj#numbernotnull,/*objectnumber*/partnumbernotnull,/*part:0=diana,1=portablepcode,2=machine-dependentpcode*/versionnumber,/*versionnumber*/piece#numbernotnull,/*piecenumber*/lengthnumbernotnull,/*piecelength*/piecelongrawnotnull)/*ub1piece*/stora
22、ge(initial10knext100kmaxextentsunlimitedpctincrease0)idl_ub1$表是用来存储PL/SQL的代码单元的,包括DIANA等,IDL在这里代表InterfaceDefinitionLanguage.这个对象的含义可以从Ixora找到一点提示:ItisanintermediatelanguageinwhichthestructureofdatabasetablesandthelogicofPL/SQLprogramunitscanbeconsistentlyrepresentedasattributedtrees.OracleusestheDI
23、ANAIDL,whichcomesfromcompilersfortheAdaprogramminglanguage.DIANAstandsforDescriptiveIntermediateAttributedNotationforAda.Anyway,thisisoneoffourtablesinthedatadictionaryusedtostoretheDIANAforPL/SQLprogramunits,andthedatabaseobjectsthattheyreference.在高级复制中会用到这个表,所以可能导致这个表快速增长,在Oracle10g之前,高级复制需要考虑的事情的确很多。
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1