zoukankan      html  css  js  c++  java
  • Oracle 12C 新特性之move (非分区表)table online

    以前版本中move table不能够online, move 会引rowid改变使对应的索引失效。 12c 中 alter table move online不会对新事务阻塞同时会自动的维护索引的有效性。

    -- 创建实验表
    SQL> create table andy_move (id int,name varchar2(10));
    Table created.
    -- 插入数据
    SQL> 
    begin
    for i in 1 .. 39 loop
    insert into andy_move values(i,'andyi');
    end loop ;
    commit;
    end;
    /
    PL/SQL procedure successfully completed.
    -- 创建索引
    SQL> create index idx_andy_id on andy_move(id);
    Index created.
    -- 查看索引状态
    SQL>
    col index_name for a25 
    select table_name,index_name,status,blevel,leaf_blocks,orphaned_entries from user_Indexes where index_name ='IDX_ANDY_ID';
    TABLE_NAME                INDEX_NAME                STATUS       BLEVEL LEAF_BLOCKS ORP
    ------------------------- ------------------------- -------- ---------- ----------- ---
    ANDY_MOVE                 IDX_ANDY_ID               VALID             0           0 NO
    -- move online 非分区表,带 online 参数
    SQL> alter table andy_move move online;
    Table altered.
    -- 查看索引状态
    SQL>
    col index_name for a25 
    select table_name,index_name,status,blevel,leaf_blocks,orphaned_entries from user_Indexes where index_name ='IDX_ANDY_ID';
    TABLE_NAME                INDEX_NAME                STATUS       BLEVEL LEAF_BLOCKS ORP
    ------------------------- ------------------------- -------- ---------- ----------- ---
    ANDY_MOVE                 IDX_ANDY_ID               VALID             0           0 NO
    -- move online 分区表 报错
    SQL> alter table p_andy move online;
    alter table p_andy move online
    *
    ERROR at line 1:
    ORA-14808: table does not support ONLINE MOVE TABLE
    -- move 非分区表 ,不带 online 参数
    delete from andy_move where id>10 and id<20;
    SQL> alter table andy_move move;
    Table altered.
    -- 查看索引状态
    SQL>
    col index_name for a25 
    select table_name,index_name,status,blevel,leaf_blocks,orphaned_entries from user_Indexes where index_name ='IDX_ANDY_ID';
    TABLE_NAME                INDEX_NAME                STATUS       BLEVEL LEAF_BLOCKS ORP
    ------------------------- ------------------------- -------- ---------- ----------- ---
    ANDY_MOVE                 IDX_ANDY_ID               UNUSABLE          0           1 NO

  • 相关阅读:
    利用正則表達式排除特定字符串
    js面向对象编程:this究竟代表什么?
    js调用父级frame中的方法
    Cocos2d-x动画工具类
    BZOJ 2466 中山市选2009 树 高斯消元+暴力
    Android Intent Scheme URLs攻击
    XML基础(一)
    【Life】 Never Too Late, Just Do it Better!
    代理模式
    HDU--Elevator(水题)
  • 原文地址:https://www.cnblogs.com/andy6/p/6852061.html
Copyright © 2011-2022 走看看