- 浏览: 219329 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
kandari:
很全,收藏
oracle相关知识 -
若见三生石:
,辛苦楼主!感谢为大伙敏捷开发做出贡献!
Oracle中的二进制、八进制、十进制、十六进制相互转换函数 -
若见三生石:
你好,要定义的类和类型怎么写呢?
Oracle中的二进制、八进制、十进制、十六进制相互转换函数 -
greatwqs:
...
PLSQL操作文件 -
sun17921:
var areaCode ={11:"北京" ...
身份证验证JS
SQL> select segment_name ,segment_type from user_segments where TABLESPACE_NAME='INDEX_TS'; SEGMENT_NAME -------------------------------------------------------------------------------- SEGMENT_TYPE ------------------ EMP_IDX INDEX EMP_PK INDEX DEPT_PK INDEX SQL> select * from emp where empno='123'; select * from emp where empno='123' * ERROR at line 1: ORA-00376: file 10 cannot be read at this time ORA-01110: data file 10: '/u01/oradata/index_ts01.ora' SQL> create tablespace index_ts_temp datafile '/u01/oradata/index_ts_temp01.ora' size 128m; connect Tablespace created. SQL> drop tablespace index_ts INCLUDING CONTENTS; drop tablespace index_ts INCLUDING CONTENTS * ERROR at line 1: ORA-00604: error occurred at recursive SQL level 1 ORA-02429: cannot drop index used for enforcement of unique/primary key SQL> alter index DEPT_PK rebuild tablespace index_ts_temp; alter index DEPT_PK rebuild tablespace index_ts_temp * ERROR at line 1: ORA-00376: file 10 cannot be read at this time ORA-01110: data file 10: '/u01/oradata/index_ts01.ora'
因为不是在线rebuild ,所以会读取原来index 的数据
SQL> alter index DEPT_PK rebuild tablespace index_ts_temp online;
Index altered.
加上online 表示不读取原来index 的数据,直接从table 里面读取数据重新建立 index
一、前一篇文章的案例中提到,索引损坏了,重建索引时,直接rebuild报错,而rebuild online则可以,这主要是两者重建索引
时的扫描方式不同,rebuild用的是“INDEX FAST FULL SCAN”,rebuild online用的是“TABLE ACCESS FULL”:
SQL> explain plan for
2 alter index ind_test_id rebuild;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
Plan hash value: 187312216
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | ALTER INDEX STATEMENT | | 115K| 565K| 78 (2)| 00:00:10 |
| 1 | INDEX BUILD NON UNIQUE| IND_TEST_ID | | | | |
| 2 | SORT CREATE INDEX | | 115K| 565K| | |
| 3 | INDEX FAST FULL SCAN| IND_TEST_ID | | | | |
--------------------------------------------------------------------------------------
10 rows selected.
SQL> explain plan for
2 alter index ind_test_id rebuild online;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------
Plan hash value: 3365522411
--------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | ALTER INDEX STATEMENT | | 115K| 565K| 78 (2)| 00:00:10 |
| 1 | INDEX BUILD NON UNIQUE| IND_TEST_ID | | | | |
| 2 | SORT CREATE INDEX | | 115K| 565K| | |
| 3 | TABLE ACCESS FULL | TEST | 115K| 565K| 78 (2)| 00:00:10 |
--------------------------------------------------------------------------------------
10 rows selected.
二、rebuild index online在执行期间不会阻塞DML操作,但在开始和结束阶段,需要请求模式为4的TM锁。因此,如果在rebuild index online开始前或结束时,有其它长时间的事物在运行,很有可能就造成大量的锁等待。具体可以参考:
rebuild index online的锁机制浅析
11G中有所不同:
rebuild index online的锁机制浅析(续)
这里可以通过设置10626事件,避免阻塞该表上的其它DML操作,但在rebuild index online开始、结束阶段有其它事物未完成,则会失败,报ORA-00051: timeout occurred while waiting for a resource 错误:
(以下测试在9208、10203中测试通过,在10201中等待几秒后,直接报ORA-00051,之后再想重建则报ORA-08104,处理方法见后面,因而设置该事件还需谨慎)
会话一:SQL> select max(sid) from v$mystat;
MAX(SID)
----------
82
SQL> delete from test_ls where id=1;
1 row deleted.
会话二:SQL> select max(sid) from v$mystat;
MAX(SID)
----------
70
SQL> alter session set events '10626 trace name context forever';
Session altered.
SQL> alter index IND_TEST_ID rebuild online;
此时会话二会话被阻塞。
会话三:SQL> delete from test_ls where id=3;
1 row deleted.
SQL> commit;
Commit complete.
SQL> select * from test_ls where id=3;
no rows selected
会话三的DML操作并不会被阻塞。
会话一rollback后,会话二报错:alter index IND_TEST_ID rebuild online
*
ERROR at line 1:
ORA-00051: timeout occurred while waiting for a resource
增加表的数据量,同样可以测出在rebuild online结束时,如果该表上还有其它事物未完成,则报错,如果无其它事物,索引可以重建成功,期间都不会阻塞其它DML操作。
三、rebuild onlie时,如果发生意外中断,很容易造成ORA-08104错误,之后再想rebuild、drop索引都会报错。10G之前需要等待SMON去清理,10G以后可以使用DBMS_REPAIR.ONLINE_INDEX_CLEAN进行手工清理:SQL> alter index IND_TEST_ID rebuild online;
alter index IND_TEST_ID rebuild online
*
ERROR at line 1:
ORA-08104: this index object 93996 is being online built or rebuilt
SQL> DECLARE
2 RetVal BOOLEAN;
3 OBJECT_ID BINARY_INTEGER;
4 WAIT_FOR_LOCK BINARY_INTEGER;
5
6 BEGIN
7 OBJECT_ID := 93996;
8 WAIT_FOR_LOCK := NULL;
9
10 RetVal := SYS.DBMS_REPAIR.ONLINE_INDEX_CLEAN ();
11 COMMIT;
12 END;
13 /
PL/SQL procedure successfully completed.
SQL> alter index ind_test_id rebuild online;
Index altered.
发表评论
-
ORACLE 中ROWNUM
2012-02-03 11:16 791对于 Oracle 的 rownum 问题,很多资料都说不 ... -
timesten内存数据库
2011-11-10 14:18 3251为什么现在内存型数据 ... -
PL/SQL集合方法、集合赋值、比较集合
2011-08-12 17:53 1206http://www.cnblogs.com/lanzi/ar ... -
oracle(集合类型)
2011-07-08 18:47 1049http://blog.sina.com.cn/s/blog_ ... -
PL/SQL Developer 设置快捷键
2011-06-20 11:47 10071、登录后默认自动选中My Objects 默认 ... -
PD常用设置和快捷键
2011-06-15 16:37 2177最近用powerDesinger ... -
PL/SQL Developer 使用技巧
2011-02-17 12:32 952http://hi.baidu.com/chssheng200 ... -
ASCII码对应表
2010-10-19 20:15 1500chr(9) tab空格 chr(10) 换行 chr(13) ... -
oracle的to_char
2010-08-20 15:02 958The following are number exam ... -
Oracle系列:Cursor
2010-07-29 17:28 9121,什么是游标? ... -
oracle job 和它的时间设置
2010-07-29 17:27 1217描述 INTERVAL参 ... -
oracle字符替换
2010-06-24 20:16 3234select REGEXP_REPLACE( 'AB ... -
update机制
2010-05-22 04:56 936就 oracle 而言 update 的时候,如果存在索引字 ... -
oracle commit
2010-05-21 09:40 1813http://blog.csdn.net/knowhow/ ... -
Oracle中的二进制、八进制、十进制、十六进制相互转换函数
2010-05-13 12:41 4454CREATE OR REPLACE PACKAGE pkg_n ... -
oracle相关知识
2010-04-28 00:16 9851.曾经不小心把开发库的数据库表全部删除,当时吓的要死。结果找 ... -
Oracle优化器Optimizer
2010-04-23 14:13 818Oracle在执行一个SQL之前, ... -
改变表空间的大小
2010-04-20 15:13 1104方法 : 如果你想把 aa.dbf 这个数据文件给缩小。 ... -
oracle的锁详解
2010-04-19 10:36 1606Oracle 多粒度锁机制介绍 根据保护对象的不同, ... -
latch的理解
2010-04-19 10:25 7511.shared pool latch和library c ...
相关推荐
@FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE', @FragmentationHigh = 'INDEX_REBUILD_ONLINE,INDEX_REBUILD_OFFLINE', @FragmentationLevel1 = 5, @...
因为使用现有索引项来重建新索引,如果客户操作时有其他用户在对这个表操作,尽量使用带online参数来最大限度的减少索引重建时将会出现的任何加锁问题,alter index index_name rebuild online。 但是,由于新旧...
For example, if the clustered index is on (lastname, firstname) and a nonclustered index is on firstname, the firstname value will not be duplicated in the nonclustered index leaf rows. Note The ...
在的文章里,我想谈下在线索引重建操作( Online Index Rebuild operations),它们在SQL Server 2014里有怎样的提升。我们都知道,自SQL Server 2005开始引入了在线索引重建操作。但这些在线操作并非真正的在线操作...
Automatic index file recovery on non-clean shutdowns. String Keys are UTF8 encoded and limited to 60 bytes if not specified otherwise (maximum is 255 chars). Support for long string Keys with the ...
Entering Comments on Check in or out 710 Check In All 711 Undo Checkout 712 Freezing an Object 713 TC Locks not selected 726 TC Locks selected 726 Working from the Command Line 738 Command Line Syntax...
SQL*Plus: Release 9.2.0.1.0 - Production on Fri Oct 31 13:53:53 2003 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. SQL> connect / as sysdba Connected to an idle instance. SQL> ...
sql> create [unique] index index_name on table_name(column,.. asc/desc) tablespace sql> tablespace_name [pctfree integer] [initrans integer] [maxtrans integer] sql> [logging | nologging] [nosort] ...
Configurable online trading time 此hack让管理员通过控制面版查看用户在线持续时间(以秒计算)。 这个时间将会在"线上人数"里面显示.phpBB 版本: 2.0.0里面显示. " Control Panel modcp Modification 类似于...
Fixed: a bug in some cases it didn't update index data for all info items but only for the last root item/branch and in result the 'Advanced search' facility may run into glitch. Version 6.3.2 Added:...
简洁明了的online,offline状态,方便地online/offline操作 ii. 详细的回滚段物理信息和当前状态。 iii. 可以方便的修改物理存储属性 表空间: i. Tablespace Map;直观的显示数据物理的在表空间上的分布 ii. ...
Hint property editor enables multi-line hint entry. Project Resource Expert for Delphi 3.0 or higher and C++Builder 3.0 or higher allows you to manage your project resource file. This expert can be ...
Sybase ASE 15.7 开发文档:系统管理指南(卷二)共两卷 第 1 章 限制对服务器资源的访问 第 2 章 镜像数据库设备 第 3 章 配置内存 第 4 章 配置数据高速缓存 第 5 章 管理多处理器服务器 第 6 章 创建和管理用户...