简体   繁体   中英

Oracle 11g Composite partition - Range | Hash

I am trying to create a table and partition it by range then sub-partition by hash. But I am getting an error. I am doubt what is wrong in the script. When we do the range partition can we specify different number of sub-partitions for the hash, like below in my example ( partition OTHER_1 having a three sub-partitions while all other partitions having two).

CREATE TABLE ACCOUNTHOLDER_P (id INT, purchased DATE, OBJECT_TYPE VARCHAR2(50), PHONE_NUMBER VARCHAR2(50)) PARTITION BY RANGE (OBJECT_TYPE)
SUBPARTITION BY HASH(PHONE_NUMBER) ( PARTITION PARTNER_1 VALUES LESS THAN ('||''''||'Partner%'||''''||') TABLESPACE USERS ( SUBPARTITION sp1 TABLESPACE ABC, SUBPARTITION sp2 TABLESPACE ABC ), PARTITION CONSUMER_1 VALUES LESS THAN ('||''''||'User%'||''''||') TABLESPACE USERS ( SUBPARTITION sp3 TABLESPACE XYZ, SUBPARTITION sp4 TABLESPACE XYZ ), PARTITION OTHER_1 VALUES LESS THAN (MAXVALUE) TABLESPACE USERS ( SUBPARTITION sp5 TABLESPACE KLM, SUBPARTITION sp6 TABLESPACE KLM, SUBPARTITION sp7 TABLESPACE KLM ));

CREATE TABLE ACCOUNTHOLDER_P (id INT, purchased DATE, OBJECT_TYPE VARCHAR2(50), PHONE_NUMBER VARCHAR2(50)) PARTITION BY RANGE (OBJECT_TYPE)
SUBPARTITION BY HASH(PHONE_NUMBER) ( PARTITION PARTNER_1 VALUES LESS THAN ('||''''||'Partner%'||''''||') TABLESPACE USERS ( SUBPARTITION sp1 TABLESPACE ABC, SUBPARTITION sp2 TABLESPACE ABC ), PARTITION CONSUMER_1 VALUES LESS THAN ('||''''||'User%'||''''||') TABLESPACE USERS ( SUBPARTITION sp3 TABLESPACE XYZ, SUBPARTITION sp4 TABLESPACE XYZ ), PARTITION OTHER_1 VALUES LESS THAN (MAXVALUE) TABLESPACE USERS ( SUBPARTITION sp5 TABLESPACE KLM, SUBPARTITION sp6 TABLESPACE KLM, SUBPARTITION sp7 TABLESPACE KLM ));

 CREATE TABLE ACCOUNTHOLDER_P (id INT, purchased DATE, OBJECT_TYPE VARCHAR2(50), PHONE_NUMBER VARCHAR2(50)) PARTITION BY RANGE (OBJECT_TYPE) 
SUBPARTITION BY HASH(PHONE_NUMBER) ( PARTITION PARTNER_1 VALUES LESS THAN ('||''''||'Partner%'||''''||') TABLESPACE USERS ( SUBPARTITION sp1 TABLESPACE ABC, SUBPARTITION sp2 TABLESPACE ABC ), PARTITION CONSUMER_1 VALUES LESS THAN ('||''''||'User%'||''''||') TABLESPACE USERS ( SUBPARTITION sp3 TABLESPACE XYZ, SUBPARTITION sp4 TABLESPACE XYZ ), PARTITION OTHER_1 VALUES LESS THAN (MAXVALUE) TABLESPACE USERS ( SUBPARTITION sp5 TABLESPACE KLM, SUBPARTITION sp6 TABLESPACE KLM, SUBPARTITION sp7 TABLESPACE KLM ));

Error :

SQL Error: ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" *Cause:
*Action:

thanks

Regards,

Era

trivial...

KLM,
   ^ that's the problem

Update after comment:

Check those single quotes. Its not clear whether you want them to belong to your partitioning value, also the percentage sign. Maybe instead of

PARTITION PARTNER_1 VALUES LESS THAN ('||''''||'Partner%'||''''||')

that would do exactly what you want:

PARTITION PARTNER_1 VALUES LESS THAN ('Partner')

Update after 2nd comment:

I can only guess that you might be looking for something like that:

select '||'''||'User%'||'''||' from dual;

||'User%'||

However, it just doesn't make sense to use that as partitioning value. Please explain what you're trying to accomplish.

Hash partitions and subpartitions should always come in powers of two -- 2, 4, 8, 16, 32 etc. -- or you end up with an uneven distribution of rows between them.

That aside, there's an example in the documentation of how to specify the number of hash subpartitions -- http://docs.oracle.com/cd/E18283_01/server.112/e16541/part_admin001.htm#i1006565

I can't imagine why you'd want to do that, though. Hash partitions are useful for improving performance of large equijoins, but that's most efficient when the joining tables have the same number of hash partitions/subpartitions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM