Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using PARTITION FOR/SUBPARTITION FOR syntax to insert

mtefftJul 13 2012 — edited Aug 8 2012
We are trying to use PARTITION FOR syntax (or, better, SUBPARTITION FOR syntax) to insert into a subpartitioned table.
http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements009.htm#i165979
08:26:46 GM_CS_CDR@oradev02> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0      Production
TNS for Solaris: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

5 rows selected.
This table is has interval partitions on DATA_ORIGIN_ID and list subpartitions on TABLE_NAME.

First, a basic insert without specifying partitions:
08:10:05 GM_CS_CDR@oradev02> insert into key_ids2 (
08:11:51   2  DATA_ORIGIN_ID         ,
08:11:51   3  TABLE_NAME             ,
08:11:51   4  DUR_UK                 ,
08:11:51   5  DUR_UK_ID              )
08:11:51   6  select
08:11:51   7  12         ,
08:11:51   8  TABLE_NAME             ,
08:11:51   9  DUR_UK                 ,
08:11:51  10  DUR_UK_ID              
08:11:51  11  from key_ids where table_name = 'PART' 
08:11:51  12  and rownum <= 10;

10 rows created.
Verifying SUBPARTITION FOR syntax on a SELECT:
08:19:43 GM_CS_CDR@oradev02> 
08:26:45 GM_CS_CDR@oradev02> 
08:26:45 GM_CS_CDR@oradev02> 
08:26:45 GM_CS_CDR@oradev02> 
08:26:45 GM_CS_CDR@oradev02> select count(*) from key_ids2 
08:26:45   2  subpartition for(12,'PART');

  COUNT(*)
----------
        10

1 row selected.
But when we add a subpartition specification (to limit the lock to a single subpartition), we get a syntax error:
08:14:57 GM_CS_CDR@oradev02> insert into key_ids2 subpartition for(12,'PART') (
08:14:57   2  DATA_ORIGIN_ID         ,
08:14:57   3  TABLE_NAME             ,
08:14:57   4  DUR_UK                 ,
08:14:57   5  DUR_UK_ID              )
08:14:57   6  select
08:14:57   7  14         ,
08:14:57   8  TABLE_NAME             ,
08:14:57   9  DUR_UK||'!'                 ,
08:14:57  10  DUR_UK_ID              
08:14:57  11  from key_ids 
08:14:57  12  where table_name = 'PART' 
08:14:57  13  and rownum <= 10;
insert into key_ids2 subpartition for(12,'PART') (
                                     *
ERROR at line 1:
ORA-14173: illegal subpartition-extended table name syntax
Specifying at the partition level did not work either:
08:14:58 GM_CS_CDR@oradev02> insert into key_ids2 partition for(14) (
08:15:23   2  DATA_ORIGIN_ID         ,
08:15:23   3  TABLE_NAME             ,
08:15:23   4  DUR_UK                 ,
08:15:23   5  DUR_UK_ID              )
08:15:23   6  select
08:15:23   7  14         ,
08:15:23   8  TABLE_NAME             ,
08:15:23   9  DUR_UK||'!'                 ,
08:15:23  10  DUR_UK_ID              
08:15:23  11  from key_ids 
08:15:23  12  where table_name = 'PART' 
08:15:23  13  and rownum <= 10;
insert into key_ids2 partition for(14) (
                                  *
ERROR at line 1:
ORA-14108: illegal partition-extended table name syntax
But specifying explicit partition and subpartition does work:
08:17:45 GM_CS_CDR@oradev02> insert into key_ids2 partition (SYS_P15127) (
08:18:23   2  DATA_ORIGIN_ID         ,
08:18:23   3  TABLE_NAME             ,
08:18:23   4  DUR_UK                 ,
08:18:23   5  DUR_UK_ID              )
08:18:23   6  select
08:18:23   7  12         ,
08:18:23   8  TABLE_NAME             ,
08:18:23   9  DUR_UK||'!'                 ,
08:18:23  10  DUR_UK_ID              
08:18:23  11  from key_ids 
08:18:23  12  where table_name = 'PART' 
08:18:23  13  and rownum <= 10;

10 rows created.

08:18:24 GM_CS_CDR@oradev02> insert into key_ids2 subpartition (SYS_SUBP15126) (
08:19:42   2  DATA_ORIGIN_ID         ,
08:19:42   3  TABLE_NAME             ,
08:19:42   4  DUR_UK                 ,
08:19:42   5  DUR_UK_ID              )
08:19:42   6  select
08:19:42   7  12         ,
08:19:42   8  TABLE_NAME             ,
08:19:42   9  DUR_UK||'!#'                 ,
08:19:42  10  DUR_UK_ID              
08:19:42  11  from key_ids 
08:19:42  12  where table_name = 'PART' 
08:19:42  13  and rownum <= 10;

10 rows created.
We have been successful in using the PARTITION FOR syntax for tables that were partitioned but not subpartitioned.

Any ideas?

Thanks,
Mike
This post has been answered by 877522 on Aug 8 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 5 2012
Added on Jul 13 2012
13 comments
10,984 views