• move或rebuild lob分区对象


    当使用如下语法移动或重建一个lob分区对象,将报错:
    SQL> alter table SHOW_LOB_STORAGE move lob(DDD) store as (tablespace PARTFORLOB03);
    ORA-14511: cannot perform operation on a partitioned object
     
    正确的语法如下:
    alter table <table name> move partition <table partition name> <table partition tablespace_name> lob (<lob column name>) store as <optional lob partition name> (tablespace <lob tablespace name>);
    alter table <table name> move partition <table partition name> <table partition tablespace_name> lob (<lob column name>) store as (tablespace <lob tablespace name>);
     
    实验如下:
    1、创建表空间
    create tablespace part_01 datafile '+DATADG' size 30M;
    create tablespace part_02 datafile '+DATADG' size 30M;
    create tablespace part_03 datafile '+DATADG' size 30M;
    create tablespace lob_01 datafile '+DATADG' size 30M;
    create tablespace lob_02 datafile '+DATADG' size 30M;
    create tablespace lob_03 datafile '+DATADG' size 30M;
    2、创建lob表分区
    create table t (aaa number(5), bbb varchar2(10), ccc number(5), ddd clob ) partition by range(aaa) (
    partition p1 values less than (50) tablespace part_01 lob (ddd) store as (tablespace lob_01),
    partition p2 values less than (100) tablespace part_02 lob (ddd) store as (tablespace lob_02),
    partition p3 values less than (maxvalue) tablespace part_03 lob (ddd) store as (tablespace lob_03));
    insert into t values (11,'a',111,'clob_a');
    insert into t values (51,'b',222,'clob_b');
    insert into t values (101,'c',333,'clob_c');
    commit;
     3、查看lob分区信息
    set pagesize 180
    col segment_name format a25
    col segment_type format a16
    col tablespace_name format a13
    col partition_name format a15
    select segment_name, segment_type, tablespace_name, partition_name from user_segments order by segment_name, partition_name;
    select partition_name, lob_partition_name, tablespace_name from user_lob_partitions where table_name = 'T';
    select table_name,def_tablespace_name from user_part_tables;
    select table_name,column_name,lob_name,lob_index_name from user_part_lobs;
    select table_name,partition_name,tablespace_name from user_tab_partitions where table_name='T';
    4、move或重建lob分区对象
    1)只迁移表分区P2中的lob对象到表空间lob_03
    alter table t move partition P2 lob(DDD) store as (tablespace lob_03);
    2)迁移表分区P1中lob对象到表空间lob_03,且重命名lob对象名称
    alter table t move partition P1 lob(DDD) store as SYS_LOB_P227_111 (tablespace lob_03);  
    3)迁移表分区P3中的lob对象到表空间 lob_01中,且表分区P3的表空间迁移到表空间 part_02
    alter table t move partition P3 tablespace part_02 lob(DDD) store as (tablespace lob_01);
    4)如果增加新的分区,还会使用用户或表默认使用的表空间,需修改分区表的表空间attribute
    alter table t modify default attributes tablespace part_new; 
    select def_tablespace_name from user_part_tables where table_name='T';

    注意:
    1、move分区表的lob对象,不应该去查user_lobs视图,而是应该去查user_lob_partitions视图。
    2、move包含有blob对象的分区表到新的表空间情形:
    ---将表分区、lob对象全move到单独一个新表空间tbs_new中,语法类似如下:
    alter table t move partition p_1 tablespace tbs_new
    lob (lob1) store as (tablespace tbs_new ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE )
    lob (lob2) store as (tablespace tbs_new ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE );
    ......
    alter table t move partition p_n tablespace tbs_new
    lob (lob1) store as (tablespace tbs_new ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE )
    lob (lob2) store as (tablespace tbs_new ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE );
    ---如果将每个表分区、每个lob对象分别存储不同的表空间,则如下:
    alter table t move partition p_1 tablespace tbs_1_1
    lob (lob1) STORE as (tablespace tbs_2_1 ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE )
    lob (lob2) store as (tablespace tbs_3_1 ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE );
    ......
    alter table t move partition p_n tablespace tbs_1_n
    lob (lob1) STORE as (tablespace tbs_2_n ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE )
    lob (lob2) store as (tablespace tbs_3_n ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 0 NOCACHE );
    3、新的分区(如interval的自动生成的新分区)还是会使用原来的(move前)表空间,需要修改分区表的默认存储表空间的属性:
    alter table t modify default attributes tablespace tbs_new;
    select def_tablespace_name from user_part_tables where table_name='T';
    此时,今后生成的新分区才会去新的表空间,而不是老的表空间。

  • 相关阅读:
    Jackson学习资料
    servlet/filter/listener/interceptor区别与联系
    JDBC、JTA、Spring的事务管理
    hibernate 的SessionFactory的getCurrentSession 与 openSession() 的区别
    Spring MVC如何配置OpenSessionInViewInterceptor并结合Hibernate使用
    SpringMVC中使用Interceptor拦截器
    Hibernate条件查询
    Spring MVC之@RequestBody, @ResponseBody 详解
    Sping Environment为Null的原因和解决方法
    SpringMVC+Thymeleaf如何处理URL中的动态查询参数
  • 原文地址:https://www.cnblogs.com/zfox2017/p/6491570.html
Copyright © 2020-2023  润新知