0

尝试使用 DBMS_CLOUD 创建间隔(或自动列表)外部分区表时,我收到 ORA-30657: operation not supported on external Organized table。

我错过了什么?

SQL> BEGIN
  2     DBMS_CLOUD.CREATE_EXTERNAL_PART_TABLE(
  3        table_name =>'PETX',
  4        credential_name =>'MY_CRED',
  5        format => json_object('delimiter' value '#'),
  6        column_list => 'deptno number,dname char(14),loc char(13)',
  7      partitioning_clause => 'partition by range (deptno) interval (15)
  8      (
  9        partition xp1 values less than (15) location(''https://swiftobjectstorage.XXXX/xp1_15.txt'') ,
 10        partition xp2 values less than (30) location (''https://swiftobjectstorage.XXXX/xp2_30.txt'')
 11      )'
 12    );
 13     END;
 14  /

Error starting at line : 5 in command -
BEGIN
   DBMS_CLOUD.CREATE_EXTERNAL_PART_TABLE(
      table_name =>'PETX',
      credential_name =>'MY_CRED',
      format => json_object('delimiter' value '#'),
      column_list => 'deptno number,dname char(14),loc char(13)',
    partitioning_clause => 'partition by range (deptno) interval (15)
    (
      partition xp1 values less than (15) location(''https://swiftobjectstorage.XXXX/xp1_15.txt'') ,
      partition xp2 values less than (30) location (''https://swiftobjectstorage.XXXX/xp2_30.txt'')
    )'
  );
   END;
Error report -
ORA-20000: ORA-30657: operation not supported on external organized table
ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD", line 1289
ORA-06512: at "C##CLOUD$SERVICE.DBMS_CLOUD", line 4115
4

1 回答 1

0

间隔和自动列表分区是根据插入到数据库中的新数据按需创建新分区的功能,其中新数据的分区键不映射到任何现有分区。对于外部表,数据库不控制数据(或数据的插入),因此插入时自动生成分区的概念不适用于外部表。

向已分区的外部表添加新分区相当于拥有该表必须指向的新数据文件。您必须告诉数据库这一点,您正在通过向表中添加新分区(手动或以编程方式)来执行此操作。

如何使上述示例工作以及如何添加新分区(指向其他数据文件)的简短示例:

SQL> 
SQL> BEGIN
  2     DBMS_CLOUD.CREATE_EXTERNAL_PART_TABLE(
  3        table_name =>'PETX',
  4        credential_name =>'MY_CRED',
  5        format => json_object('delimiter' value '#'),
  6        column_list => 'deptno number,dname char(14),loc char(13)',
  7      partitioning_clause => 'partition by range (deptno)
  8      (
  9        partition xp1 values less than (15) location(''https://swiftobjectstorage.XXXX/xp1_15.txt'') ,
 10        partition xp2 values less than (30) location (''https://swiftobjectstorage.XXXX/xp2_30.txt'')
 11      )'
 12    );
 13     END;
 14  /

PL/SQL procedure successfully completed.

SQL> 
SQL> alter table petx add partition xp3 values less than (50) location ('https://swiftobjectstorage.XXXX/xp3_45.txt');

Table PETX altered.

SQL> select count(*) from petx partition (xp3);

  COUNT(*)
----------
  49999999

PS:完全相同的行为适用于标准 Oracle 数据库。

于 2021-10-08T16:11:31.203 回答