ITPub博客

首页 > Linux操作系统 > Linux操作系统 > alter table modify Long=>LOB会重建整张表

alter table modify Long=>LOB会重建整张表

原创 Linux操作系统 作者:viadeazhu 时间:2010-09-02 18:00:05 0 删除 编辑

refer to 11 Migrating Columns from LONGs to LOBs in 《Oracle Database Application Developer's Guide - Large Objects》:

Note:

The ALTER TABLE statement copies the contents of the table into a new space, and frees the old space at the end of the operation. This temporarily doubles the space requirements.
 
所以当我们使用ALTER TABLE MODIFY LONG to LOB之后,其实整张表被重建了,因此,所有的index需要重建。
以前我没注意这个知识点,特此记录一下。
 
这里可以通过rowid都变了来验证。
 
SQL> create table testlong (id number,name long);
Table created.
 
SQL> insert into testlong select object_id,object_name from dba_objects;
10065 rows created.
 
SQL> commit;
Commit complete.
 
SQL> create index testlongidx on testlong(id);
Index created.
 
SQL> create table beforeconvert as select id,rowid rid from testlong; 
Table created.
 
SQL>  alter table testlong modify name clob;
Table altered.
 
SQL> create table afterconvert as select id,rowid rid from testlong; 
Table created.
 
SQL> select count(*) from beforeconvert b ,afterconvert a
  2  where a.id=b.id
  3  and a.rid=b.rid;
  COUNT(*)
----------
     0
    
SQL> select status from dba_indexes where index_name='TESTLONGIDX';    
STATUS
--------
UNUSABLE
 
   

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15415488/viewspace-672483/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-08-22

  • 博文量
    79
  • 访问量
    392348