Oracle数据库中索引的维护
Oracle数据库中索引的维护 本文只讨论Oracle中最常见的索引,即是B-tree索引。本文中涉及的数据库版本是Oracle8i。一. 查看系统表中的用户索引在Oracle中,SYSTEM表是安装数据库时自动建立的,它包含数据库的全部数据字典,存储过程、包、函数和触发器的定义以及系统回滚段。一般来说,应该尽量避免在SYSTEM表中存储非SYSTEM用户的对象。因为这样会带来数据库维护和管理的很多问题。一旦SYSTEM表损坏了,只能重新生成数据库。我们可以用下面的语句来检查在SYSTEM表内有没有其他用户的索引存在。select count(*) from dba_indexes where t
Oracle 8i回滚段
回滚段中保存的回滚数据有2个作用:一致读和回滚。回滚段是由连续block组成的区间extent组成.回滚段有顺序的循环的使用这些区间。 当当前区间写满的时候,oracle移向下一个区间. 如一个回滚段有4个区间A,B,C,D;当区间C被写满的时候,oracle将写区间D,而当D写满的时候,oracle将尝试重新写区间A.这样循环的有顺序的使用区间。 事务必须将回滚信息写到回滚段中;事务的当前新产生的回滚信息写在该回滚段的位置叫做回滚段的head. 而在该回滚段上最早发生的尚未提交的事务最早产生的回滚信息所在位置叫做回滚段的tail. 当前区间写满的时候,or
数据库系统中事务的ACID原则
事务的原子性、一致性、独立性及持久性 事务的原子性是指一个事务要么全部执行,要么不执行.也就是说一个事务不可能只执行了一半就停止了.比如你从取款机取钱,这个事务可以分成两个步骤:1划卡,2出钱.不可能划了卡,而钱却没出来.这两步必须同时完成.要么就不完成. 事务的一致性是指事务的运行并不改变数据库中数据的一致性.例如,完整性约束了a+b=10,一个事务改变了a,那么b也应该随之改变. 事务的独立性是指两个以上的事务不会出现交错执行的状态.因为这样可能会导致数据不一致. 事务的持久性是指事务运行成功以后,就系统的更新是永久的.不会
Oracle常用数据字典
视图名 描述 ALL_CATALOG All tables, views, synonyms, sequences accessible to the user ALL_COL_COMMENTS Comments on columns of accessible tables and views ALL_COL_GRANTS_MADE Grants on columns for which the user is owner or grantor ALL_COL_GRANTS_RECD Grants on columns for which the user or PUBLIC is the grantee ALL_COL_PRIVS Grants on columns for which the user is the grantor, grantee, owner, or an enabled role or PUBLIC is the grantee ALL_COL_PRIVS_MADE Grants on columns for which the user
安装Oracle后,经常使用的修改表空间的SQL代码
配置:Windows NT 4.0 中文版5块10.2GB SCSI硬盘分:C:盘、D:盘、E:盘、F:盘、G:盘Oracle 8.0.4 for Windows NTNT安装在C:WINNT,Oracle安装在C:ORANT目标:因系统的回滚段太小,现打算生成新的回滚段,建立大的、新的表空间(数据表空间、索引表空间、回滚表空间、临时表空间、)建两个数据表空间、两个索引表空间,这样建的目的是根据实际应用,如:现有10个应用用户,每个用户是一个独立子系统(如:商业进销存MIS系统中的财务、收款、库存、人事、总经理等)尤其大型商场中收款机众多,同时访问进程很多,经常达到50-100个进程同时访问
常用用户SQL
表: select * from cat; select * from tab; select table_name from user_tables; 视图: select text from user_views where view_name=upper('&view_name'); 索引: select index_name,table_owner,table_name,tablespace_name,status from user_indexes order by table_name; 触发器: select trigger_name,trigger_type,table_owner,table_name,status from user_triggers; 快照: select owner,name,master,table_name,last_refresh,next from user_snapshots order by owner,next; 同义词:
常用监控SQL
1.监控事例的等待: select event,sum(decode(wait_time,0,0,1)) prev, sum(decode(wait_time,0,1,0)) curr,count(*)from v$session_wait group by event order by 4;2.回滚段的争用情况:select name,waits,gets,waits/gets ratio from v$rollstat a,v$rollname b where a.usn=b.usn;3.监控表空间的I/O比例:select df.tablespace_name name,df.file_name "file",f.phyrds pyr,f.phyblkrd pbr,f.phywrts pyw,f.phyblkwrt pbw from v$filestat f,dba_data_files dfwhere f.file#=df.file_id4.监空文件系统的I/O比例:se
常用ASCII 码对照表
ASCII码键盘ASCII 码键盘ASCII 码键盘ASCII 码键盘27ESC32SPACE33!34"35#36$37%38&39'40(41)42*43+44'45-46.47/48049150251352453554655756857958:59;60<61=62>63?64@65A66B67C68D69E70F71G72H73I74J75K76L77M78N79O80P81Q82R83S84T85U86V87W88X89Y90Z91[9293]94^95_96`97a98b99c100d101e102f103g104h105i106j107k108l109m110n111o112p113q114r115s116t117u118v119w120x121y122z123{124|125}126[@more@]
Analyze table
v_percent constant number := 40;type t_obj_names is table of user_objects.object_name%type;v_tables t_obj_names := t_obj_names();cursor c_t isselect /*+ALL_ROWS*/table_namefrom user_tableswhere tablespace_name = 'AA'and substr(table_name, 1, 1) not in ('S');beginn := 0;for r in c_t loopv_tables.extend;n := n + 1;v_tables(n) := r.table_name;end loop;for i in 1 .. n loopbegindbms_stats.gather_table_stats(user,v_tables(i),estimate_percent => v_percent);commit;exceptionwhen others thenrollback;co