Creating SubPartitions

Hi,
I have a table which is almost 1 TB and partitioned daily using interval partitioning. However, we are getting more than 100 million rows per day. So, I would like to create hash sub-partitions based on one of the columns. Since the table is so huge and we ultimately purge the old data, I want to create sub-partitions only on future partitions. Is there a way to do this withyout affecting existing partitions ? I would appreciate any suggestions.
Thanks
Naresh

Lets start learning partitioning in Oracle by docs :
First I will read concept what exactly is partitioning.... (I am rereading it, because I have some doubts, next time I can answer any question related to partitioning, because my knowledge source is docs)
http://docs.oracle.com/cd/B28359_01/server.111/b32024/partition.htm
Now, your question :
Can't I create the partition after creating the table and then subpartition it.Yes, you can. You have two options :
1.DBMS_REDEFINITION
2.ALTER TABLE Statement
Ok, where are good example as well as explanation? Again docs are my friend.
1.http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_redefi.htm#ARPLS042
2.http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_3001.htm#i2087440
Have friendship with docs, have friendship with ultimate success....!
Regards
Girish Sharma

Similar Messages

  • Help to create SUBPARTITIONS

    HI,
    I am getting error while creating a SUBPARTITION for my table.
    CREATE TABLE Tab1
    col1 NUMBER(12),
    col2 CHAR(1 BYTE),
    col3 CHAR(1 BYTE),
    col4 NUMBER(12)
    PARTITION BY LIST (col1 )
    SUBPARTITION BY HASH (col4)
    SUBPARTITION TEMPLATE(
    SUBPARTITION SP_1 TABLESPACE C_D
    PARTITION PAR_0 VALUES (0)
    TABLESPACE C_D
    Error
    SUBPARTITION BY HASH (col4)
    ERROR at line 9:
    ORA-00922: missing or invalid option
    The syntax is all correct... i am not understanding where i am going wrong. Can anyone tell me my mistake.
    Thanks
    Sami

    What Hoek said is correct, at least for 10.2.
    11.2 supports list/hash and your code works as expected (after changing the tablespace to users):
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    SQL> CREATE TABLE Tab1
      2  (
      3  col1 NUMBER(12),
      4  col2 CHAR(1 BYTE),
      5  col3 CHAR(1 BYTE),
      6  col4 NUMBER(12)
      7  )
      8  PARTITION BY LIST (col1 )
      9  SUBPARTITION BY HASH (col4)
    10  SUBPARTITION TEMPLATE(
    11  SUBPARTITION SP_1 TABLESPACE users
    12  )
    13  (
    14  PARTITION PAR_0 VALUES (0)
    15  )
    16  TABLESPACE users;
    Table created.
    SQL>But you didn't tell us your Oracle version so.....

  • AVOID Subpartition(list) to be created when Splitting Main Partition(range)

    I have created a table structure as below:
    CREATE TABLE TEST_SUBPARTITIONS_1
    RECORD_ID INTEGER NOT NULL,
    SUB_ID VARCHAR2(100),
    COBDATE DATE,
    DESC VARCHAR2(2000)
    PARTITION BY RANGE (COBDATE)
    SUBPARTITION BY list(SUB_ID)
    PARTITION INITIAL_PARTITION VALUES LESS THAN (TO_DATE(' 2200-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    TABLESPACE TBS_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE
    INITIAL 64K
    NEXT 1M
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    (SUBPARTITION INITIAL_SUBPARTITION VALUES ('INITIAL_DUMMY_SUB_ID') TABLESPACE TBS_DATA
    CREATE UNIQUE INDEX TEST_SUBPARTITIONS_1_PK ON TEST_SUBPARTITIONS_1 (COBDATE, RECORD_ID, SUB_ID) LOCAL;
    ALTER TABLE TEST_SUBPARTITIONS_1 ADD CONSTRAINT TEST_SUBPARTITIONS_1_PK PRIMARY KEY (COBDATE, RECORD_ID, SUB_ID);
    I am partitioning the table based on range (COBDATE) and subpartitioning based on list (SUB_ID).
    The table now is created with initial partitions and initial subpartition.
    We are splitting the partitions in our procedure as below
    ALTER TABLE TEST_SUBPARTITIONS_1 SPLIT PARTITION
    TST_SUB_R21001231 AT (TO_DATE(20130220,'YYYYMMDD') ) INTO
         (PARTITION TST_SUB_R20130219 TABLESPACE TBS_DATA, PARTITION TST_SUB_R21001231)
    The partition is getting split correctly with new partition as
    TST_SUB_R20130219, but the subpartition is also created automatically with some 'SYS' name.
    (i.e Name: SYS_SUBP693 , Values: INITIAL_DUMMY_SUB_ID)
    This happens after every split of range by COBDATE.
    Here it has created as below:
    Partition          SubPartition
    TST_SUB_R21001231     INITIAL_SUBPARTITION
    TST_SUB_R20130219     SYS_SUBP693
    TST_SUB_R20130220     SYS_SUBP694
    TST_SUB_R20130221     SYS_SUBP695
    I want to AVOID splitting subpartition when I split the main partition
    i.e a SYS subpartition should not be created when I split the partition for COBDATE.
    Let me know how do I avoid this in main "alter statement" above?
    Any other solution?     I do not want to drop the SYS subpartition later, instead want it to avoid creating only when I split the partition.

    >
    I want to AVOID splitting subpartition when I split the main partition
    i.e a SYS subpartition should not be created when I split the partition for COBDATE.
    Let me know how do I avoid this in main "alter statement" above?
    Any other solution? I do not want to drop the SYS subpartition later, instead want it to avoid creating only when I split the partition.
    >
    The subpartitions aren't being split. Oracle is creating new subpartitions for the new partition. The subpartitions need to exist since that is where the data is stored.
    You can avoid the SYS prefix on the name though by using a different naming convention.
    See the 'Splitting a *-List Partition' section of the VLDB and Partitioning Guide
    http://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm#i1008028
    >
    The ALTER TABLE ... SPLIT PARTITION statement provides no means of specifically naming subpartitions resulting from the split of a partition in a composite partitioned table. However, for those subpartitions in the parent partition with names of the form partition name_subpartition name, the database generates corresponding names in the newly created subpartitions using the new partition names. All other subpartitions are assigned system generated names of the form SYS_SUBPn. System generated names are also assigned for the subpartitions of any partition resulting from the split for which a name is not specified. Unnamed partitions are assigned a system generated partition name of the form SYS_Pn.

  • Subpartition with MOD Function in Oracle 11g

    Hi All,
    Can we create Subpartition based on MOD Function in Oracle 11g ?

    Hi!
    What are you refering with "MTS"? Anybody knows a term like this (except MultiThreaded Server).

  • Subpartition issue.

    Hello Folks,
    I am having 1 table, and it has 3 partitions and one of it's having max value and I want to create subpartition inside that partition. When I have created subpartition it's got created with system generated name. When I am trying to explicitly specify that name it's throwing me below error.
    alter table x_event split partition LOG_MAX
    AT(TO_DATE(' 2012-01-01 00:00:00','SYYYY-MM-DD HH24:MI:SS','NLS_CALENDAR=GREGORIAN'))
    INTO (PARTITION Y11M12 SUBPARTITIONS Y11M12_FSM VALUES('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) UPDATE GLOBAL INDEXES ; 2 3
    INTO (PARTITION Y11M12 SUBPARTITIONS Y11M12_FSM VALUES('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) UPDATE GLOBAL INDEXES
    ERROR at line 3:
    ORA-14156: invalid number of subpartitions specified in [SUBPARTITIONS |
    SUBPARTITION TEMPLATE] clause
    has anybody has got the same issue before ?

    HG,
    I tried using the code you posted here but it got lots of syntax errors and moreover it has subpatition by list and trying to use hash subpartitioning style. So based on your information, i created table with 3 range partitions a list partitions (see sql for more details).
    Sql for creating range/list composite partitioned table
    CREATE TABLE klondike.xlog_event (
    xlog_even_id NUMBER (38) NOT NULL,
    xlog_date DATE NOT NULL,
    xlog_id NUMBER (38) NOT NULL,
    xlog_event_type_id NUMBER (38) NOT NULL,
    xlog_event_status_id NUMBER (38) NOT NULL,
    detail_count NUMBER (38) NOT NULL,
    start_date timestamp (6) NOT NULL,
    end_date timestamp (6) NOT NULL
    TABLESPACE xlog_event_data
    LOGGING
    PARTITION BY RANGE (xlog_date)
    SUBPARTITION BY LIST (xlog_event_type_id)
    *(PARTITION y09m12*
    VALUES LESS THAN
    *( (TO_DATE ('2010-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')))*
    LOGGING
    NOCOMPRESS
    TABLESPACE xlog_event_data
    *(SUBPARTITION sub_y09m12 VALUES (200) TABLESPACE xlog_event_data),*
    PARTITION y10m12
    VALUES LESS THAN
    *( (TO_DATE ('2011-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')))*
    LOGGING
    NOCOMPRESS
    TABLESPACE xlog_event_data
    *(SUBPARTITION sub_y10m12 VALUES (300) TABLESPACE xlog_event_data),*
    PARTITION xlog_max
    VALUES LESS THAN (maxvalue)
    LOGGING
    NOCOMPRESS
    TABLESPACE xlog_event_data
    SUBPARTITION y06_fsm
    VALUES (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_fsd
    VALUES (50, 51, 52, 53, 54, 55, 56, 57, 58, 59)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_mis
    VALUES (40, 41, 42, 43, 44, 45, 46, 47, 48, 49)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_imp
    VALUES (20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_omp
    VALUES (30, 31, 32, 33, 34, 35, 36, 37, 38, 39)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_iep
    VALUES (60, 61, 62, 63, 64, 65, 66, 67, 68, 69)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_oep
    VALUES (70, 71, 72, 73, 74, 75, 76, 77, 78, 79)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_emd
    VALUES (80, 81, 82, 83, 84, 85, 86, 87, 88, 89)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_man
    VALUES (100, 101, 102, 103, 104, 105, 106, 107, 108, 109)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_evt
    VALUES (110, 111, 112, 113, 114, 115, 116, 117, 118, 119)
    TABLESPACE xlog_event_data,
    SUBPARTITION y06_msa
    VALUES (90, 91, 92, 93, 94, 95, 96, 97, 98, 99)
    TABLESPACE xlog_event_data
    Later I split LOG_MAX patition and split subpatition Y06_FSM into Y11M12_FSM , see below for synatx.
    ALTER TABLE XLOG_EVENT
    SPLIT SUBPARTITION Y06_FSM
    VALUES (0,1,2,3,4)
    INTO (SUBPARTITION Y11M12_FSM  TABLESPACE XLOG_EVENT_DATA
    *, SUBPARTITION Y06_FSM)*
    UPDATE GLOBAL INDEXES;
    ALTER TABLE xlog_event
    SPLIT PARTITION xlog_max AT
    *((TO_DATE('2012-01-01 00:00:00','YYYY-MM-DD HH24:MI:SS')))*
    INTO (PARTITION y11m12
    TABLESPACE xlog_event_data
    *, PARTITION xlog_max);*
    Once you are done later you can rename system generated subpartition name with your choice of name using following
    E.g.
    ALTER TABLE XLOG_EVENT   RENAME SUBPARTITION SYS_SUBP143  TO Y11M12_1;
    Let me know if this helps you out and answer your question.
    Regards

  • Add sub partition on another column in oracle

    I have a table which has two partitions (by range): first_half and second_half based on a column "INSERT_DAY".
    I need to add subpartitions "SUCCESS" and "NONSUCCESS" based on the values of another column "STATUS" (subpartition by list) i.e. I need to transform my range partition to composite (range-list) partition.
    I do not wish to drop existing tables or partitions. What is the ALTER query for this?
    PS: The database is Oracle 9i

    Ok, my bad. The project is about charging GPRS customers for data usage.
    Here is the real DDL:
    CREATE TABLE CDR_EVENT_RCD_FILE_MOB_AGG
       (    "MOBILE_NO" VARCHAR2(16 BYTE),
        "DATA_VOLUME" NUMBER(*,0),
        "CHARGE" NUMBER(*,0),
        "RECORD_COUNT" NUMBER(*,0),
        "COUNTER" NUMBER(*,0) DEFAULT 0,
        "INSERT_DAY" NUMBER(*,0),
        "MAX_FILE_SEQ_NO" NUMBER(*,0),
        "MIN_FILE_SEQ_NO" NUMBER(*,0),
        "REQUEST_ID" VARCHAR2(21 BYTE),
        "TRANSACTION_ID" VARCHAR2(21 BYTE),
        "RESPONSE_TIME" TIMESTAMP (6),
        "RETURN_CODE" CHAR(2 BYTE),
        "FAILURE_REASON" VARCHAR2(1024 BYTE),
        "CHARGED_AMOUNT" NUMBER(*,2)
      PARTITION BY RANGE ("INSERT_DAY")
    (PARTITION "FIRST_HALF"  VALUES LESS THAN (16)  ,
    PARTITION "SECOND_HALF"  VALUES LESS THAN (MAXVALUE) ) ;
      CREATE INDEX "CDRDEVTBS"."MAX_FILE_SEQ_NO_INDEX" ON "CDRDEVTBS"."CDR_EVENT_RCD_FILE_MOB_AGG" ("MAX_FILE_SEQ_NO") ;
      CREATE INDEX "CDRDEVTBS"."MOBILE_NO_INDEX" ON "CDRDEVTBS"."CDR_EVENT_RCD_FILE_MOB_AGG" ("MOBILE_NO") ;
    As you can see, it is partitioned by range on "Insert_day".
    The requirement is to delete all the records having counter=3 (which means successful charging) for the records which are older than 15 days.
    So I thought, why not create sub partitions with counter so that final DDL would be something like the following. I would then avoid writing a DELETE query, which would take a lot of time to execute.
    CREATE TABLE CDR_EVENT_RCD_FILE_MOB_AGG (
        insert_day INT,
        counter INT,
    --other columns
    PARTITION BY RANGE (insert_day)
    SUBPARTITION BY LIST(counter)
    SUBPARTITION TEMPLATE
        SUBPARTITION SUCCESS VALUES(3),
        SUBPARTITION NONSUCCESS VALUES(DEFAULT)
        PARTITION first_half VALUES LESS THAN (16),
        PARTITION second_half VALUES LESS THAN (maxvalue)
    So that I could execute queries:
    alter table CDR_EVENT_RCD_FILE_MOB_AGG  truncate subpartition first_half_success; --execute on last day of every month
    alter table CDR_EVENT_RCD_FILE_MOB_AGG  truncate subpartition second_half_success; -- execute on 16th day of every month
    to remove unnecessary records.
    I would like to create subpartitions without dropping the existing table.

  • List-range partition

    Hi Oracle Gurus,
    I have a table with list partition, as the partitions are growing large I need to create subpartitions.
    Is it possible to create a range subpartition under list partition. If yes I need that subpartition to be built on time not on date.
    Is it possible.

    While range-list partitioning exists in 10g, list-range partitioning to the best of my knowledge does not exist. There are some new options in 11g but I can't remember what they are off the top of my head. You can check the on-line documentation to see what your partitioning options are
    Your partitioning options will depend on what version of Oracle you are using. Also remember that you need the licence to use the partitioning feature

  • Create table with day wise subpartition in 11g

    Hi
    how to create day wise subpartition & year wise partion in 11g

    shd wrote:
    I have created partition table using non-partiiton structure.
    now i m inserting data from non-partition to partition table but i got error
    ORA-14400: inserted partition key does not map to any partitionHow you created parittion table?
    Hows your non partitioned table looks like and sample data?
    How you wish to partition it?
    More over you can use DBMS_REDEFINITION. The following privileges must be granted to the user to run DBMS_REDEFINITION: (PRIVILEGES FOR DBMS_REDEFINITION)
    ALTER ANY TABLE
    CREATE ANY TABLE
    DROP ANY TABLE
    LOCK ANY TABLE
    SELECT ANY TABLE
    CREATE ANY INDEX
    CREATE ANY TRIGGER
    Regards
    Girish Sharma

  • Creating Materialized View in Toad

    As with every new endeavor - come new questions.
    I am trying to create a materialized view via toad (first time doing this). Now - toad is great, since it provides a kind-of wizard interface. Hence, one doesn't have to completely code in the create statement, with all of the options, etc.
    Instead, in toad, one can (via the schema browser), go into the Materialized Views tab and click on create new. This opens a window with 6 tabs: Basic Info, Refresh Info, Physical Attributes, Query, Partitions & Subpartition Template.
    In the Basic Info, one can put a check mark next to some of the following options:
    -Build Deffered
    -Parallel
    -Cache
    -Logging
    -Using index
    -Allow updates
    etc.
    I have read that build deferred refers to whether or not you would like the view to be created automatically or to be deferred.
    Anyways, I tried to find Toad documentation to explain each of the options in-detail. No success. Hence, am researching each part piece by piece.
    But - here is my question:
    In the Query tab, we are asked to specify a query. I am assuming that the query does not have to be a full query, beginning with CREATE MATERIALIZED VIEW mv_table1 REFRESH FAST etc...
    Since in this 'wizard', we are providing the MV name at the top of the dialog box, we are checking the 'options' in the other tabs, etc.
    And so, I assumed that the query should merely be a select query in the window mentioned above.
    So I entered the following:
    select * from table1@remote_db;
    When I go to verify the syntax, I get the error message: ORA_00911: invalid character. It seems to be pointing to my db_link (remote_db). I have been using this link throughout many places, w/o any problems.
    Has anyone created a MV in toad before? Any links to good toad documentation would be helpful as well.
    Thanks.

    (This is fun... ;))
    For anyone endeavoring this in the future, below I have attached the prerequisites required in order to create a materialized view (can also be found @ http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_6002.htm):
    Prerequisites
    The privileges required to create a materialized view should be granted directly rather than through a role.
    To create a materialized view in your own schema:
    You must have been granted the CREATE MATERIALIZED VIEW system privilege and either the CREATE TABLE or CREATE ANY TABLE system privilege.
    You must also have access to any master tables of the materialized view that you do not own, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a materialized view in another user's schema:
    You must have the CREATE ANY MATERIALIZED VIEW system privilege.
    The owner of the materialized view must have the CREATE TABLE system privilege. The owner must also have access to any master tables of the materialized view that the schema owner does not own (for example, if the master tables are on a remote database) and to any materialized view logs defined on those master tables, either through a SELECT object privilege on each of the tables or through the SELECT ANY TABLE system privilege.
    To create a refresh-on-commit materialized view (ON COMMIT REFRESH clause), in addition to the preceding privileges, you must have the ON COMMIT REFRESH object privilege on any master tables that you do not own or you must have the ON COMMIT REFRESH system privilege.
    To create the materialized view with query rewrite enabled, in addition to the preceding privileges:
    If the schema owner does not own the master tables, then the schema owner must have the GLOBAL QUERY REWRITE privilege or the QUERY REWRITE object privilege on each table outside the schema.
    If you are defining the materialized view on a prebuilt container (ON PREBUILT TABLE clause), then you must have the SELECT privilege WITH GRANT OPTION on the container table.
    The user whose schema contains the materialized view must have sufficient quota in the target tablespace to store the master table and index of the materialized view or must have the UNLIMITED TABLESPACE system privilege.
    When you create a materialized view, Oracle Database creates one internal table and at least one index, and may create one view, all in the schema of the materialized view. Oracle Database uses these objects to maintain the materialized view data. You must have the privileges necessary to create these objects.

  • How to truncate data in a subpartition

    Hi All,
    I am using oracle 11gr2 database.
    I have a table as given below
    CREATE TABLE SCMSA_ESP.PP_DROP
    ESP_MESSAGE_ID VARCHAR2(50 BYTE) NOT NULL ,
    CREATE_DT DATE DEFAULT SYSDATE,
    JOB_LOG_ID NUMBER NOT NULL ,
    MON NUMBER GENERATED ALWAYS AS (TO_CHAR("CREATE_DT",'MM'))
    TABLESPACE SCMSA_ESP_DATA
    PARTITION BY RANGE (JOB_LOG_ID)
    SUBPARTITION BY LIST (MON)
    PARTITION PMINVALUE VALUES LESS THAN (1)
    ( SUBPARTITION PMINVALUE_M1 VALUES ('01') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M2 VALUES ('02') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M3 VALUES ('03') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M4 VALUES ('04') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M5 VALUES ('05') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M6 VALUES ('06') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M7 VALUES ('07') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M8 VALUES ('08') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M9 VALUES ('09') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M10 VALUES ('10') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M11 VALUES ('11') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMINVALUE_M12 VALUES ('12') TABLESPACE SCMSA_ESP_DATA
    PARTITION PMAXVALUE VALUES LESS THAN (MAXVALUE)
    ( SUBPARTITION PMAXVALUE_M1 VALUES ('01') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M2 VALUES ('02') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M3 VALUES ('03') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M4 VALUES ('04') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M5 VALUES ('05') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M6 VALUES ('06') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M7 VALUES ('07') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M8 VALUES ('08') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M9 VALUES ('09') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M10 VALUES ('10') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M11 VALUES ('11') TABLESPACE SCMSA_ESP_DATA,
    SUBPARTITION PMAXVALUE_M12 VALUES ('12') TABLESPACE SCMSA_ESP_DATA
    ENABLE ROW MOVEMENT;
    I have populate two sets of data.
    One with Positive job_log_id and another with Negative job logid as given below.
    Step 1:
    Data going to PMAXVALUE Partition
    INSERT INTO PP_DROP ( ESP_MESSAGE_ID, CREATE_DT,JOB_LOG_ID)
    SELECT LEVEL, SYSDATE+TRUNC(DBMS_RANDOM.VALUE(1,300)), 1 FROM DUAL CONNECT BY LEVEL <=300;
    Step 2:
    Data going to PMINVALUE partition
    INSERT INTO PP_DROP ( ESP_MESSAGE_ID, CREATE_DT,JOB_LOG_ID)
    SELECT LEVEL, SYSDATE+TRUNC(DBMS_RANDOM.VALUE(1,300)), -1 FROM DUAL CONNECT BY LEVEL <=300;
    Now the question is how to truncate the data that is present only in the Positive partitions subpartition
    Like in the PMAXVALUE partition I have 10 subpartitions and I need to truncate the data in the JAN MONTH Partition only of the PMAXVALUE partition.
    Appreciate your valuable response.
    Thanks,
    MK.

    For future reference:
    http://www.morganslibrary.org/reference/truncate.html
    The library index is located at
    http://www.morganslibrary.org/library.html

  • Moving Subpartitions to a duplicate table in a different schema.

    +NOTE: I asked this question on the PL/SQL and SQL forum, but have moved it here as I think it's more appropriate to this forum. I've placed a pointer to this post on the original post.+
    Hello Ladies and Gentlemen.
    We're currently involved in an exercise at my workplace where we are in the process of attempting to logically organise our data by global region. For information, our production database is currently at version 10.2.0.3 and will shortly be upgraded to 10.2.0.5.
    At the moment, all our data 'lives' in the same schema. We are in the process of producing a proof of concept to migrate this data to identically structured (and named) tables in separate database schemas; each schema to represent a global region.
    In our current schema, our data is range-partitioned on date, and then list-partitioned on a column named OFFICE. I want to move the OFFICE subpartitions from one schema into an identically named and structured table in a new schema. The tablespace will remain the same for both identically-named tables across both schemas.
    Do any of you have an opinion on the best way to do this? Ideally in the new schema, I'd like to create each new table as an empty table with the appropriate range and list partitions defined. I have been doing some testing in our development environment with the EXCHANGE PARTITION statement, but this requires the destination table to be non-partitioned.
    I just wondered if, for partition migration across schemas with the table name and tablespace remaining constant, there is an official "best practice" method of accomplishing such a subpartition move neatly, quickly and elegantly?
    Any helpful replies welcome.
    Cheers.
    James

    You CAN exchange a subpartition into another table using a "temporary" (staging) table as an intermediary.
    See :
    SQL> drop table part_subpart purge;
    Table dropped.
    SQL> drop table NEW_part_subpart purge;
    Table dropped.
    SQL> drop table STG_part_subpart purge;
    Table dropped.
    SQL>
    SQL> create table part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition p_1 values less than (10) (subpartition p_1_s_1 values ('A'), subpartition p_1_s_2 values ('B'), subpartition p_1_s_3 values ('C'))
      5  ,
      6  partition p_2 values less than (20) (subpartition p_2_s_1 values ('A'), subpartition p_2_s_2 values ('B'), subpartition p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create index part_subpart_ndx on part_subpart(col_1) local;
    Index created.
    SQL>
    SQL>
    SQL> insert into part_subpart values (1,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'A');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'B');
    1 row created.
    SQL> insert into part_subpart values (2,'C');
    1 row created.
    SQL> insert into part_subpart values (11,'A');
    1 row created.
    SQL> insert into part_subpart values (11,'C');
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL>
    SQL> create table NEW_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  partition by range (col_1) subpartition by list (col_2)
      3  (
      4  partition n_p_1 values less than (10) (subpartition n_p_1_s_1 values ('A'), subpartition n_p_1_s_2 values ('B'), subpartition n_p_1_s_3 values ('C'))
      5  ,
      6  partition n_p_2 values less than (20) (subpartition n_p_2_s_1 values ('A'), subpartition n_p_2_s_2 values ('B'), subpartition n_p_2_s_3 values ('C'))
      7  )
      8  /
    Table created.
    SQL>
    SQL> create table STG_part_subpart(col_1  number not null, col_2 varchar2(30))
      2  /
    Table created.
    SQL>
    SQL> -- ensure that the Staging table is empty
    SQL> truncate table STG_part_subpart;
    Table truncated.
    SQL> -- exchanging a subpart out of part_subpart
    SQL> alter table part_subpart exchange subpartition
      2  p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL> -- exchanging the subpart into NEW_part_subpart
    SQL> alter table NEW_part_subpart exchange subpartition
      2  n_p_2_s_1 with table STG_part_subpart;
    Table altered.
    SQL>
    SQL>
    SQL> select * from NEW_part_subpart subpartition (n_p_2_s_1);
         COL_1 COL_2
            11 A
    SQL>
    SQL> select * from part_subpart subpartition (p_2_s_1);
    no rows selected
    SQL>I have exchanged subpartition p_2_s_1 out of the table part_subpart into the table NEW_part_subpart -- even with a different name for the subpartition (n_p_2_s_1) if so desired.
    NOTE : Since your source and target tables are in different schemas, you will have to move (or copy) the staging table STG_part_subpart from the first schema to the second schema after the first "exchange subpartition" is done. You will have to do this for every subpartition to be exchanged.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Apr 4, 2011 10:19 AM
    Added clarification for cross-schema exchange.

  • Error  while creating partition

    Hi All,
    I am trying to create a composite RANGE-LIST partition on a table.
    I am trying to create a range partition on a insertdate column and a list subpartition on last 2 digits of a phone number. So, each partition should have 100 subpartition.
    The syntax goes like this.
    CREATE TABLE TEST_PART
    Insertdate date,
    phone_no number(10),
    col1 varchar2(20),
    col2 varchar2(20))
    PARTITION BY RANGE (INSERTDATE)
    SUBPARTITION BY LIST( (SUBSTR(PHONE_NO,-2))
    SUBPARTITION template(
    SUBPARTITION value00('00') ,
    SUBPARTITION value01('01'),
    SUBPARTITION value02('02'))
    PARTITION P1 VALUES LESS THAN (TO_DATE(' 2006-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PARTITION P2 VALUES LESS THAN (TO_DATE(' 2006-01-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PARTITION P3 VALUES LESS THAN (TO_DATE(' 2006-01-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    But this is giving the following error:
    ORA-00904: : invalid identifier
    Can't I use SUBSTR here? Is there any way of doing partition ?
    Thanks,
    Reks

    According to the documentation, you can only use a column_name there. If you correct, this one, there are some more errors in your statment:
    values keyword in the subpartition definitions
    the partitions clause must be enclosed by parentheses
    each partition clause must be separated by a comma.
    The following statement is syntactically valid, but it is may be not what you want. Is it possible that you subpartition by hash? Why list subpartitioning? Is subpartitioning needed at all?
    CREATE TABLE TEST_PART 
    Insertdate date, 
    phone_no varchar2(10), 
    col1 varchar2(20), 
    col2 varchar2(20))  
    PARTITION BY RANGE (INSERTDATE) 
    SUBPARTITION BY LIST( PHONE_NO )
    SUBPARTITION template(
    SUBPARTITION value00 values('00'),  -- now this makes no sense anymore
    SUBPARTITION value01 values('01'),  -- now this makes no sense anymore
    SUBPARTITION value02 values('02'))  -- now this makes no sense anymore
    PARTITION P1 VALUES LESS THAN (TO_DATE(' 2006-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
    PARTITION P2 VALUES LESS THAN (TO_DATE(' 2006-01-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
    PARTITION P3 VALUES LESS THAN (TO_DATE(' 2006-01-03 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    /

  • Where did the Partitions and SubPartitions go?

    I created a table with partition Range (Transaction_Date, Retention_Period) and hash (Record_Id) subpartition template (for 32 subpartitions)
    Then I add more partitions and while the loop is going on I can get counts of partitions and subpartitions. The job finished and my log table shows about 1800 partitions added and there should be 32 subpartitions for each of the partitions. However, user_tab_partitions shows zero records for the table, and user_tab_subpartitions also show zero record. After a few minutes the partitions show up but no subpartitions. The indexes on the table have also disappeared (one local and one global)
    Any explanation for this behaviour?
    Working on Exadata 11.2.0.3
    Querying
    USER_TABLES
    USER_TAB_PARTITIONS
    USER_TAB_SUBPARTITIONS
    USER_INDEXES

    >
    Step 1. Create Table xyz (c1 date, c2 integer c3 integer, etc)
    partition by range (c1,c2)
    subpartition template (s01, s02... s32)
    create index i1 on xyz (c1,c2,c3) local;
    Then, since I want to create about 1800 partitions I have a procedure that has a "loop around" ALTER TABLE add Partition .. until all the partitions are created. This is the "Job" which while running I query USER_TAB_PARTITIONS and USER_TAB_SUBPARTITIONS to see how things are progressing. And Yes ALTER Table has no progressing to verify.
    So al the partitions get created. No errors from the procedure to go through creating all the partitions. So I would expect that at the end I should get to see all the new partitions for the Table. Instead I get "no records" from USER_TAB_PARTITIONS and USER_TAB_SUBPARTITIONS.
    I am also aware that "ALTER TABLE ADD PARTITION .." cannot make indexes go away. However, if the query on USER_INDEXES returns nothing, what happend to the Index created before the partitions were added?
    I am not using DBMS_REDEFINITION. The only procedure is to add partitions one at a time for each date for 3 years. If you have a better way than a procedure please advise accordingly.
    >
    In order to help you the first step is to understand what problem you are dealing with. Then comes trying to determine what options are available for addressing the problem. There are too many times , and yours may, or may not, be another one, where people seem to have settled on a solution before they have really identified the problem.
    Anytime someone mentions the use of dynamic SQL it raises a red flag. And when that use is for DDL, rather than DMl, it raises a REALLY BIG red flag.
    Schema objects need to be managed properly and the DDL that creates them needs to be properly written and kept in some sort of version control.
    Scripts and procedures that use dynamic SQL are more properly used to create DDL, not to execute it. That is, rather than use a procedure to dynamically create or alter a table you would use the procedure to dynamically create a DDL script that would create or alter the table.
    Let's assume that you know for certain that your table really needs to have 1800 partitions, be subpartitioned the way you say and have partition and subpartitions names that you assign. Well, that would be a pain to hand-write 1800 partition definitions.
    So you would create a procedure that would produce a CREATE TABLE script that had the proper clauses and syntax to specify those 1800 partitions. Your 'loop' would not EXECUTE an ALTER TABLE for each partition but would create the partition specification and modify the partition boundaries for each iteration through the loop. Sort of like
    for i from 1 to 365 loop
        add partition spec for startDate + i
    end loop;The number of iterations would be a parameter and you would start with 2 or 3. Always test with the smallest code that will produce the correct results. If the code works for 3 days it will work for any larger reasonable number.
    Then you would save that script in your version control system and run it to create the table. There would be nothing to monitor since there is just one script and when it is done it is done.
    That would be a proper use of dynamic sql: to produce DDL, not to execute it.
    Back to your issue. If I were your manager then based on what you posted I would expect you to already have
    1. a requirements document that stated the problem (e.g. performance, data management) that was being addressed
    2. test results that showed that your proposed solution (a table partitioned the way you posted) solves the problem
    The requirements doc would have detail about what the performance/management issues are and what impact they are having
    You also need to document what the possible solutions are, the relative merits of each solution and the factors you considered when ranking the solutions. That is, why is your particular partitioning scheme the best solution for the problem.
    You should have test results that show the execution plans and performance you achieved by using a test version of your proposed table and indexes.
    Until you have 'proven' that your solution will work as you expect I wouldn't recommend implementing the full-blown version of it.
    1. Create a table MANUALLY that has 2 or three days worth of partitions.
    2. Load those partitions with a representative amount of data
    3. Execute test queries to query data from one of those partitions
    4. Execute the same test queries against your current table
    5. Capture the execution plans (the actual ones) for those queries. Verify that you are getting the performance improvements that you expected.
    Once ALL of that prep work is done and you have concluded that your table/index design is correct then go back to work on writing a script/procedure that will produce (not execute) DDL to produce the main table and partitioning you designed.
    Just an aside on what you posted. The indexes should be created AFTER the table and its partitions are created. If you are creating your local index first, as you post suggests, you are forcing Oracle to revamp it 1800 times when each partition is added. Just create the index after the table.
    p.s. the number of posts anyone has is irrevelant. The only thing that matters is whether the advice or suggestions they provide is helpful. And the helpfullness of those is limited to, and based on, ONLY the information a poster provides. For exampe, your proposed partitioning scheme might be perfectly appropriate for your use case or it could be totally inappropriate. We have no way of knowing without knowing WHY you chose that scheme.
    But I haven't seen one like that so it makes me suspicious that you really need to get that complicated.

  • Doubt in subpartitioning of a table

    hi gems...good evening..
    I have a table which previously had only range partitions.
    Now I changed it to range-hash composite partitioning.
    There are 6 partition tablespaces namely TS_PART1, TS_PART2.....TS_PART 6.
    The default tablespace of the schema is TS_PROD.
    The table had following structure previously:
    create table ORDER_BOOK
    CUST_ID NUMBER(10),
    PROFILE_ID NUMBER(10),
    PRODUCT_ID NUMBER(10),
    SUB_PROFILE_ID VARCHAR2(25),
    CASHFLOW_DATE DATE,
    EARNINGS NUMBER(24,6),
    constraint ORDER_BOOK_PK primary key(CUST_ID,PROFILE_ID,PRODUCT_ID,SUB_PROFILE_ID,CASHFLOW_DATE)
    partition by range (CASHFLOW_DATE)
    partition ORDER_BOOK_PART1 values less than (TO_DATE('01-01-2003', 'DD-MM-YYYY')) tablespace TS_PART1,
    partition ORDER_BOOK_PART2 values less than (TO_DATE('01-01-2006', 'DD-MM-YYYY')) tablespace TS_PART2,
    partition ORDER_BOOK_PART3 values less than (TO_DATE('01-01-2009', 'DD-MM-YYYY')) tablespace TS_PART3,
    partition ORDER_BOOK_PART4 values less than (TO_DATE('01-01-2012', 'DD-MM-YYYY')) tablespace TS_PART4,
    partition ORDER_BOOK_PART5 values less than (TO_DATE('01-01-2015', 'DD-MM-YYYY')) tablespace TS_PART5,
    partition ORDER_BOOK_PART6 values less than (TO_DATE('01-01-2018', 'DD-MM-YYYY')) tablespace TS_PART6
    create index ORDER_BOOK_IDX on ORDER_BOOK(PRODUCT_ID,CASHFLOW_DATE);
    Now I did the following steps to change the previously existing partitions to the new range-hash composite partitions:
    begin
    dbms_redefinition.can_redef_table
    (uname=>'DEMO_TEST',
    tname=>'ORDER_BOOK',
    options_flag=>DBMS_REDEFINITION.CONS_USE_PK);
    end;
    create table INTERIM_ORDER_BOOK
    CUST_ID NUMBER(10),
    PROFILE_ID NUMBER(10),
    PRODUCT_ID NUMBER(10),
    SUB_PROFILE_ID VARCHAR2(25),
    CASHFLOW_DATE DATE,
    EARNINGS NUMBER(24,6),
    constraint INTERIM_ORDER_BOOK_PK primary key(CUST_ID,PROFILE_ID,PRODUCT_ID,SUB_PROFILE_ID,CASHFLOW_DATE)
    partition by range(CASHFLOW_DATE)
    subpartition by hash (CUST_ID)
    subpartition template
    subpartition SP1 tablespace TS_PART1,
    subpartition SP2 tablespace TS_PART2,
    subpartition SP3 tablespace TS_PART3,
    subpartition SP4 tablespace TS_PART4,
    subpartition SP5 tablespace TS_PART5,
    subpartition SP6 tablespace TS_PART6
    (partition P1 values less than (to_date('01-01-2003','DD-MM-YYYY')),
    partition P2 values less than (to_date('01-01-2006','DD-MM-YYYY')),
    partition P3 values less than (to_date('01-01-2009','DD-MM-YYYY')),
    partition P4 values less than (to_date('01-01-2012','DD-MM-YYYY')),
    partition P5 values less than (to_date('01-01-2015','DD-MM-YYYY')),
    partition P6 values less than (to_date('01-01-2018','DD-MM-YYYY')))
    enable row movement;
    begin
    dbms_redifinition.start_redef_table
    (uname=>'DEMO_TEST',
    orig_table=>'ORDER_BOOK',
    int_table=>'INTERIM_ORDER_BOOK',
    options_flag=>DBMS_REDEFINITION.CONS_USE_PK);
    end;
    begin
    dbms_redefinition.finish_redef_table
    (uname=>'DEMO_TEST',
    orig_table=>'ORDER_BOOK',
    int_table=>'INTERIM_ORDER_BOOK');
    end;
    After that I made the index with LOCAL clause i.e local index.
    But the problem is that...initially when there is only range partitioning, then the datas are going to the corresponding partition tablespaces.
    But after modifying the table, populating the table results in consumption of space in both partition tablespaces as well as the default tablespace.
    I have checked the size of the tablespaces. From that I came to know about this.
    The output of the USER_TAB_SUBPARTITIONS is okk...every subpartitions are in the corresponding tablespaces.
    But the main partitions (USER_TAB_PARTITION) are in the default tablespace.
    please help me....thanks in advance...
    Edited by: user12780416 on Apr 13, 2012 7:46 AM

    user12780416 wrote:
    Thanks sir for your reply...
    Yes, by MOVE syntax I can move the partitions in the corresponding tablespaces.
    But i am not getting the reason of consumption of both the tablespaces.
    The TS_PART1 increased 2MB, TS_PART2 increased 6MB, TS_PART3 increased 2MB, TS_PART4 increased 5MB, TS_PART5 increased 9MB.
    and TS_PROD increased (2+6+2+5+9)=24MB
    Why is this happening ?
    I have read that when we make subpartitions, they main partitions are the logical entity only and the subpartitions are the physical entity.Where have you read this?
    As RP rightly pointed out, you can specify a tablespace for each partition (each partition using a different tablespace) and a tablespace for each subpartitions (again, using many if you felt like it).

  • Problem creating LOB segment

    Hi all,
    I'm working with 11gR2 version in RAC environment with 2 nodes. I'm creating the schemes on my new database with empty tablespaces and 100Mb of initial free space. I'm having an error on the creation of this table:
    CREATE TABLE "IODBODB1"."DOCUMENTOS"
    (     "ID_DOC" NUMBER NOT NULL ENABLE,
         "ID_APP" NUMBER(5,0) NOT NULL ENABLE,
         "ID_CLS" NUMBER(6,0) NOT NULL ENABLE,
         "CREATE_FEC" DATE NOT NULL ENABLE,
         "LAST_MODIFIED_FEC" DATE NOT NULL ENABLE,
         "DOC_NAME" VARCHAR2(100 BYTE) NOT NULL ENABLE,
         "DOC_SIZE" NUMBER NOT NULL ENABLE,
         "DOC_DATA" BLOB NOT NULL ENABLE,
         "CLASE_FORMATO_FORMATO" VARCHAR2(150 BYTE),
         "REGULAR_NAME" VARCHAR2(100 BYTE) NOT NULL ENABLE,
         "USUARIO" VARCHAR2(25 BYTE),
         "USUARIO_LEVEL" VARCHAR2(5 BYTE)
    ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE(BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "ODBODB_TBD_DADES"
    LOB ("DOC_DATA") STORE AS BASICFILE (ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 10 NOCACHE LOGGING STORAGE( BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
    PARTITION BY LIST ("ID_APP")
    SUBPARTITION BY RANGE ("ID_DOC")
    PARTITION "PTL_DOCUMENTOS_FICTICIO" VALUES (0) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
    STORAGE(BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "ODBODB_TBD_DADES"
    LOB ("DOC_DATA") STORE AS BASICFILE (ENABLE STORAGE IN ROW CHUNK 8K PCTVERSION 10 NOCACHE LOGGING STORAGE(BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
    (SUBPARTITION "PTR_DOCUMENTOS_FICTICIO" VALUES LESS THAN (MAXVALUE) LOB ("DOC_DATA") STORE AS (TABLESPACE "ODBODB_TBL_LOBS" ) TABLESPACE "ODBODB_TBD_DADES" NOCOMPRESS ) );
    PARTITION "PTL_DOCUMENTOS_ALFIMG" VALUES (2) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
    STORAGE(BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "ODBODB_TBD_DADES"
    LOB ("DOC_DATA") STORE AS BASICFILE (ENABLE STORAGE IN ROW CHUNK 32K PCTVERSION 10 NOCACHE LOGGING STORAGE(BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT))
    (SUBPARTITION "STR_DOCUMENTOS_ALFIMG" VALUES LESS THAN (MAXVALUE) LOB ("DOC_DATA") STORE AS (TABLESPACE "BEALFIMG_TBL_ODB" ) TABLESPACE "BEALFIMG_TBD_ODB" NOCOMPRESS )
    The error is:
    ORA-03252: initial extent size not enough for LOB segment
    I can't understand how Oracle can't allocate enough extents to create the LOB segment, and I don't know to which LOB segment it refers because the sqlplus don't mark it with the error.
    Any ideas about this issue?
    Thanks in advance!
    dbajug

    Please, forget this post, I feel dumb... The LOB segment need to have same size of the rest of partition...

Maybe you are looking for