Creating partitions on table

Hi All,
My developer came with a requirement of creating paritions on a table which has 40 million records. His exact requirement is to create as many as partitions in such a way that 1 partition should not exceed 5k-10k records and these records should be inserted/updated on the same date (i.e. using source time stamp field).
How to accomplish this?
Thanks in advance.
Regards
Hari

Hi;
I suggest close your issue here as answered than move your issue Forum Home » Database » SQL and PL/SQL which you can get more quick response
Regard
Helios

Similar Messages

  • Create partitions on table

    Hi All,
    My developer came with a requirement of creating paritions on a table which has 40 million records. His exact requirement is to create as many as partitions in such a way that 1 partition should not exceed 5k-10k records and these records should be inserted/updated on the same date (i.e. using a column as source_timestamp field).
    How to accomplish this?
    Thanks in advance.
    Regards
    Hari

    >
    My developer came with a requirement of creating paritions on a table which has 40 million records. His exact requirement is to create as many as partitions in such a way that 1 partition should not exceed 5k-10k records and these records should be inserted/updated on the same date (i.e. using a column as source_timestamp field).
    How to accomplish this?
    >
    My first question wouldl be why are you letting a developer dictate what the architecture should be?
    The architecture should be based on the business requirements. So what exactly are the business requirements?
    How is the table going to be queried?
    Partitions of onlyl 5-10k records are extremely small and will likely only be useful if the filter predicates on the queries match the partition key.
    You need to provide more information about what is really needed and some sample data and query that shows that.
    If the source_timestamp field values are such that there are 5-10k records for each day then you could create a simple interval partitioned table on TRUNC(source_timestamp).
    DROP TABLE SCOTT.PARTITION_DAILY_TEST CASCADE CONSTRAINTS;
    CREATE TABLE SCOTT.PARTITION_DAILY_TEST
      ID       NUMBER(10),
      MY_DATE  DATE
    PARTITION BY RANGE (MY_DATE)
    INTERVAL( NUMTODSINTERVAL(1,'DAY'))
      PARTITION P_EXISTING_20120401 VALUES LESS THAN (TO_DATE(' 2012-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    );

  • Creating Partitions in Existing tables with Data

    Hello everyone,
    I want to know what the best way of creating partitions, in tables having data, is .. ???
    thanks
    Rossy Rocs

    There are two ways :
    1a Create a new Partitioned Table
    1b Copy data from the existing table to the new table
    1c Create Indexes
    1d Rename old table
    1e Rename new table
    OR
    2 Use DBMS_REDEFINITION
    See
    http://www.oracle-base.com/articles/misc/PartitioningAnExistingTable.php
    Hemant K Chitale

  • Status of VIEW after partitioning base table.

    Hi All,
    I would like to know the status of the view when i perform Range partitioning on Base table???
    I will be performing these below steps for partitioning:
    1. Rename the Original base table.
    2. Create new partitioned table by naming it as original table name.
    3. Insert rows from Original table to partitioned table.
    As from above steps i am renaming the original base table and creating Partitioned base table with the same original name.
    Do VIEWS based on this table will refer to new partitioned table having same name, or do i need to re-create views???
    -Yasser

    View refers to NEW Partition TABLE on the same name... it's not the problem.. if you didn't rename delete add column_name.
    SQL> create table a1 (id number);
    Table created.
    SQL> create view v_a1 as select * from a1;
    View created.
    SQL> desc v_a1;
    Name                         Null? Type
    ID                                  NUMBER
    SQL> alter table a1 rename to a2;
    Table altered.
    SQL> desc v_a1;
    ERROR:
    ORA-24372: invalid object for describe
    SQL> create table a1 (id varchar2(40))
    2 /
    Table created.
    SQL> desc v_a1;
    Name                         Null? Type
    ID                                  VARCHAR2(40)

  • Error while creating partition table

    Hi frnds i am getting error while i am trying to create a partition table using range
    getting error ORA-00906: missing left parenthesis.I used the following statement to create partition table
    CREATE TABLE SAMPLE_ORDERS
    (ORDER_NUMBER NUMBER,
    ORDER_DATE DATE,
    CUST_NUM NUMBER,
    TOTAL_PRICE NUMBER,
    TOTAL_TAX NUMBER,
    TOTAL_SHIPPING NUMBER)
    PARTITION BY RANGE(ORDER_DATE)
    PARTITION SO99Q1 VALUES LESS THAN TO_DATE(‘01-APR-1999’, ‘DD-MON-YYYY’),
    PARTITION SO99Q2 VALUES LESS THAN TO_DATE(‘01-JUL-1999’, ‘DD-MON-YYYY’),
    PARTITION SO99Q3 VALUES LESS THAN TO_DATE(‘01-OCT-1999’, ‘DD-MON-YYYY’),
    PARTITION SO99Q4 VALUES LESS THAN TO_DATE(‘01-JAN-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q1 VALUES LESS THAN TO_DATE(‘01-APR-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q2 VALUES LESS THAN TO_DATE(‘01-JUL-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q3 VALUES LESS THAN TO_DATE(‘01-OCT-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q4 VALUES LESS THAN TO_DATE(‘01-JAN-2001’, ‘DD-MON-YYYY’)
    ;

    More than one of them. Try this instead:
    CREATE TABLE SAMPLE_ORDERS
    (ORDER_NUMBER NUMBER,
    ORDER_DATE DATE,
    CUST_NUM NUMBER,
    TOTAL_PRICE NUMBER,
    TOTAL_TAX NUMBER,
    TOTAL_SHIPPING NUMBER)
    PARTITION BY RANGE(ORDER_DATE) (
    PARTITION SO99Q1 VALUES LESS THAN (TO_DATE('01-APR-1999', 'DD-MON-YYYY')),
    PARTITION SO99Q2 VALUES LESS THAN (TO_DATE('01-JUL-1999', 'DD-MON-YYYY')),
    PARTITION SO99Q3 VALUES LESS THAN (TO_DATE('01-OCT-1999', 'DD-MON-YYYY')),
    PARTITION SO99Q4 VALUES LESS THAN (TO_DATE('01-JAN-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q1 VALUES LESS THAN (TO_DATE('01-APR-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q2 VALUES LESS THAN (TO_DATE('01-JUL-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q3 VALUES LESS THAN (TO_DATE('01-OCT-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q4 VALUES LESS THAN (TO_DATE('01-JAN-2001', 'DD-MON-YYYY')))In the future, if you are having problems, go to Morgan's Library at www.psoug.org.
    Find a working demo, copy it, then modify it for your purposes.

  • Error in creating partition table in oracle spatial by ankur

    Hi,
    Am working on Oracle 10.2.0.3
    Am not able to create partition table in Oracle
    i have all the required columns in node and edge table ......the moment i try to create partition table using exec sdo_router_partition.partion_router i get the following error:
    ERROR at line 1:
    ORA-00947: not enough values
    ORA-06512: at "MDSYS.SDO_ROUTER_PARTITION", line 1510
    ORA-06512: at "MDSYS.SDO_ROUTER_PARTITION", line 661
    ORA-06512: at line 1
    Can someone help ??

    hey i have found the solution myself :)

  • PL/SQL- Problem in creating a partitioned fact table using select as syntax

    Hi All,
    I am trying to create a clone(mdccma.fact_pax_bkng_t) of existing fact table (mdccma.fact_pax_bkng) using dynamic pl/sql. However, pl/sql anonymous block errors out with following error:
    SQL> Connected.
    SQL> SQL> DECLARE
    ERROR at line 1:
    ORA-00911: invalid character
    ORA-06512: at "SYS.DBMS_SYS_SQL", line 1608
    ORA-06512: at "SYS.DBMS_SQL", line 33
    ORA-06512: at line 50
    Here is pl/sql block:
    -- CREATING FPB_T
    DECLARE
    v_owner VARCHAR2(32) := 'MDCCMA';
    v_table_original VARCHAR2(32) := 'FACT_PAX_BKNG';
    v_table VARCHAR2(32) := 'FACT_PAX_BKNG_T';
    v_tblspc VARCHAR2(32) := v_owner||'_DATA';
    CURSOR c_parts IS SELECT TABLESPACE_NAME, PARTITION_NAME,HIGH_VALUE, ROW_NUMBER() OVER (ORDER BY PARTITION_NAME) AS ROWNUMBER
    FROM USER_TAB_PARTITIONS
    WHERE TABLE_NAME = v_table_original
    ORDER BY PARTITION_NAME;
    v_cmd CLOB := EMPTY_CLOB();
    v_cmd3 varchar2(300) := 'CREATE TABLE ' ||v_owner||'.'||v_table||' TABLESPACE '||v_tblspc
    ||' NOLOGGING PARTITION BY RANGE'||'(' ||'SNAPSHOT_DTM '||')' ||'(';
    v_part VARCHAR2(32);
    v_tblspc_name VARCHAR2(32);
    v_row number;
    v_value LONG;
    v_tmp varchar2(20000);
    v_cur INTEGER;
    v_ret NUMBER;
    v_sql DBMS_SQL.VARCHAR2S;
    v_upperbound NUMBER;
    BEGIN
    v_cmd := v_cmd3;
    OPEN c_parts;
    FETCH c_parts INTO v_tblspc_name, v_part,v_value, v_row;
    WHILE c_parts%FOUND
    LOOP
    IF (v_row = 1) THEN
    v_tmp := ' PARTITION '||v_part||' VALUES LESS THAN ' ||'('|| v_value||')'||' NOLOGGING TABLESPACE '||v_tblspc_name;
    ELSE
    v_tmp := ', PARTITION '||v_part||' VALUES LESS THAN ' ||'('|| v_value||')'||' NOLOGGING TABLESPACE '||v_tblspc_name;
    END IF;
    v_cmd := v_cmd || v_tmp;
    -- DBMS_OUTPUT.PUT_LINE(v_cmd);
    FETCH c_parts INTO v_tblspc_name, v_part,v_value, v_row;
    END LOOP;
    -- DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_cmd));
    v_cmd := v_cmd||')'||' AS SELECT ' || '*'||' FROM ' || v_owner||'.'|| v_table_original ||' WHERE '||'1'||'='||'2'||';';
    v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_cmd)/256);
    FOR i IN 1..v_upperbound
    LOOP
    v_sql(i) := DBMS_LOB.SUBSTR(v_cmd
    ,256 -- amount
    ,((i-1)*256)+1 -- offset
    END LOOP;
    v_cur := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
    v_ret := DBMS_SQL.EXECUTE(v_cur);
    CLOSE c_parts;
    DBMS_OUTPUT.PUT_LINE(v_cmd);
    -- EXECUTE IMMEDIATE v_cmd ;
    END;
    The above pl/sql creates a DDL for partitioned fact table(new) based on an existing fact table and get executes through CLOB.
    Please look into the issue and let me know any changes or modifications/suggestions that are required to fix the issue. Any help is appreciated.
    Thank You,
    Sudheer

    Think this is your problem:
    v_cmd := v_cmd||')'||' AS SELECT ' || '*'||' FROM ' || v_owner||'.'|| v_table_original ||' WHERE '||'1'||'='||'2'||';';Remove the SQL terminator ';' ... dynamic SQL doesn't require it, try this instead:
    v_cmd := v_cmd||')'||' AS SELECT ' || '*'||' FROM ' || v_owner||'.'|| v_table_original ||' WHERE '||'1'||'='||'2';Thanks
    Paul

  • How to create partition from one table to another?

    Hi,
    Can any one help me in this :
    I have copied table from one schema to another by using the following command. The table is around 300 GB in size and the partitions are not copied. Now i got a request to create partitions in the destination table similar to the source table.
    CREATE TABLE user2.table_name AS SELECT * FROM  user1.table_name;
    I am using Oracle 9i database. This is very urgent, could any one please suggest me how can i create the partitions in  user2 table as user1 table.

    If you have the TOAD/ SQL DEVELOPER  , get the partition DDL from the source table and execute it in the newly created table.
    or you can use DBMS_METADATA:
    SET LONG 10000
    SELECT dbms_metadata.get_ddl('TABLE', 'TEST')
    FROM DUAL;
    Thanks,
    <Moderator Edit - deleted link signature - pl see FAQ link on top right>

  • Create Partition tables in PL/SQL using Execute Immediate

    Hi
    I have to create a partiton table in PL/SQL using Execute Immediate. I concat the necessary Create Table syntax into a variable and use Execute Immediate variable name. This gives a error ORA-00900: invalid SQL statement. However if i cut and paste the SQL statement from DBMS_OUTPUT, the table creation goes through without any problem.
    What could be the issue. Has anyone face this before please.
    I am using 10G DB

    Thanks for your reply. It is a big code. I am pasting the part required.
    v_sqlstmtout :='CREATE TABLE a_10(MYDATE DATE NOT NULL,ID NUMBER(14) NOT NULL)';
    v_sqlstmtout := v_sqlstmtout || ' PARTITION BY RANGE (MYDATE) ';
    v_sqlstmtout := v_sqlstmtout || 'SUBPARTITION BY HASH(id) ';
    v_sqlstmtout := v_sqlstmtout || 'SUBPARTITION TEMPLATE(';
    v_sqlstmtout := v_sqlstmtout || 'SUBPARTITION SP1,SUBPARTITION SP2) ';
    v_sqlstmtout := v_sqlstmtout || '(PARTITION mth_dummy VALUES LESS THAN ';
    v_sqlstmtout := v_sqlstmtout || '('||V_SQLSTMT3||')' || v_sqlstmt||')';
    EXECUTE IMMEDIATE ''''||v_sqlstmtout||'''';
    variables are substituted through data from different tables.
    The output looks like the following
    CREATE TABLE a_10(MYDATE DATE NOT NULL,ID NUMBER(14) NOT NULL)
    PARTITION BY RANGE (mydate) SUBPARTITION BY HASH(id) SUBPARTITION
    TEMPLATE(SUBPARTITION SP1,SUBPARTITION SP2) (PARTITION mth_dummy VALUES
    LESS THAN ('01-MAY-2006'), PARTITION mth_JAN2007 VALUES LESS THAN
    ('01-FEB-2007'))
    The above is the output from DBMS_OUTPUT. If i run this statement the table is created. Please help..

  • Can we create partitions in an existing table?

    Hi,
    Can we create partitions in an existing table which has about a million rows? I am using oracle 9i database.
    Can any one suggest me on this please.

    07b3ea8e-c4c5-4559-9055-ed38853dc64e wrote:
    Hi,
    Can we create partitions in an existing table which has about a million rows? I am using oracle 9i database.
    Can any one suggest me on this please.
    can NOT be done.
    research DBMS_REDEFINITION

  • How to create a paritioned table from a partitioned table

    I have a paritioned table and I want to create a similar table which should be a partitioned table with the same data.
    Can anyone let me know the way to do it.
    thanks in advance...

    1) create the table with the same ddl (with a name change) as with which the other table was created and then simply INSERT all the data.
    2) export the table and import the table in another schema or database.
    HTH,
    L.

  • Create partition table upto level 3

    Hi All,
    I want to create partition table using 3 columns. could you please tell me is that possible to do in oracle 11G. if can please tell me the way to create
    PARTITION BY LIST (Acct_type)
    SUBPARTITION BY LIST (PERIOD)
    and needs to partition this using another column.( account_source)
    please help me.
    Regards,
    krish

    Hello,
    3 levels of partition are not possible.
    But perhaps you can combine 2 levels as follows:
    With Oracle 11g you can use a virtual column:
    CREATE TABLE F_ACCOUNT_PART
    acc_type varchar2(100),
    acc_source varchar2(100),
    period date,
    acc_type_source varchar2(201) as (acc_type||'_'||acc_source) )
    PARTITION BY LIST (acc_type_source)
    PARTITION FA_AA_ACC1 VALUES ('AA-ACC1') TABLESPACE USERS,
    PARTITION FA_BB_ACC1 VALUES ('BB-ACC1') TABLESPACE USERS,
    PARTITION FA_CC_ACC1 VALUES ('CC-ACC1') TABLESPACE USERS,
    PARTITION FA_DD_ACC1 VALUES ('DD-ACC1') TABLESPACE USERS,
    PARTITION FA_AA_ACC2 VALUES ('AA-ACC2') TABLESPACE USERS,
    PARTITION FA_BB_ACC2 VALUES ('BB-ACC2') TABLESPACE USERS,
    PARTITION FA_CC_ACC2 VALUES ('CC-ACC2') TABLESPACE USERS,
    PARTITION FA_DD_ACC2 VALUES ('DD-ACC2') TABLESPACE USERS,
    PARTITION all_other VALUES (DEFAULT) TABLESPACE USERS
    )For versions prior to 11g you have to build a new column acc_type_source and fill the values cancatenated.
    Maik

  • Unable to Create Partitioned Table

    Hi All,
    I was trying to create a partitioned table using following
    Create table customers (custcode number(5),
    Name varchar2(20),
    Addr varchar2(10),
    City varchar2(20),
    Bal number(10,2))
    Partition by list (city),
    Partition north_India values (‘DELHI’,’CHANDIGARH’),
    Partition east_India values (‘KOLKOTA’,’PATNA’),
    Partition south_India values (‘HYDERABAD’,’BANGALORE’,’CHENNAI’),
    Partition west India values (‘BOMBAY’,’GOA’);
    It is throwing me an error
    ORA-00922: missing or invalid option
    Will you please tell me what is wrong with this query? Is it possible to create partitioned table using select statement (create table as select... Partition by...)?
    Regards
    ~Pravin

    Pravin
    Will you please tell me what is wrong with this query?I see 4 errors in the syntax. Therefore, I strongly suggest you to have a lock to this:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2146309
    In addition, have a look to the error message. If I run your script in SQL*Plus it clearly shows where the problem is. E.g.:
    SQL> Create table customers (custcode number(5),
      2  Name varchar2(20),
      3  Addr varchar2(10),
      4  City varchar2(20),
      5  Bal number(10,2))
      6  Partition by list (city),
      7  Partition north_India values (‘DELHI’,’CHANDIGARH’),
      8  Partition east_India values (‘KOLKOTA’,’PATNA’),
      9  Partition south_India values (‘HYDERABAD’,’BANGALORE’,’CHENNAI’),
    10  Partition west India values (‘BOMBAY’,’GOA’);
    Partition by list (city),
    ERROR at line 6:
    ORA-00922: missing or invalid option
    Is it possible to create partitioned table using select statement?Yes. With the usual syntax.
    HTH
    Chris Antognini
    Author of Troubleshooting Oracle Performance, Apress 2008 (http://top.antognini.ch)

  • Create Partitioning to non-partitioning Table

    Dear All,
    I have a table which is non partitioning and it has about 20G data... If I want to partition this table with column say DATE_M,
    Please can anyone suggest the best way to do this.
    Thanks

    So now in the partitioned table he creates one maxvalue partition and does exchange partition 
    That isn't the typical scenario. Typically you make the switch by using partitions for the NEW data and leave the existing data in the base range partition.
    1. Existing app uses an unpartitioned table
    2. New table is partitioned for NEW DATA
    Assume you want monthly partitions (daily works the same). This is already April so there is already some April data.
    So create the partitioned table so the base partition clause includes ALL of the data for April and before:
    create table ipart 
      (time_id date 
      ,cust_id number(4) 
      ,amount_sold number(5)) 
      partition by range(time_id) 
      interval(NUMTOYMINTERVAL(1,'month')) 
      (partition old_data values less than (to_date('01-may-2015','DD-MON-YYYY'))) 
    Now you do the exchange with the unpartitioned table and all the current data goes into that 'OLD_DATA' partition.
    New data for May and the future will have partitions created automatically.
    That approach lets you ease into partitioning without disrupting your current processes at all.
    As time goes by more and more of the data will be in the new monthly partitions. If you need to you can split that base partition
    insert into ipart (time_id) values (sysdate - 90);
    insert into ipart (time_id) values (sysdate - 60);
    insert into ipart (time_id) values (sysdate - 30);
    insert into ipart (time_id) values (sysdate);
    commit;
    alter table ipart split partition old_data
      at (to_date('01-jan-2015', 'DD-MON-YYYY')) into
      (partition old_data, partition JAN_FEB_MAR_APR);

  • Problem while partitioning The Table

    create table Employee ( empno number(3), name varchar2(10), deptno number(4))
    partition by range(deptno)
    (partition p1 values less than(11),
    partition p2 values less than(21),
    partition p3 values less than(31));
    create table Employee (
    ERROR at line 1:
    ORA-00439: feature not enabled: Partitioning
    Please help me for solving this problem and send me the details I need to partition my table.
    Thanks in advance.
    w.regards
    R.Satish

    Looks like you don't have partition license or don't have a complete install of Oracle version 8.0.5. The best way to check is do a sqlplus user/passwd and look for a message that said "Production with the Partitioning and objects options" to appear before the SQL> prompt. Hope this helps....
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by rkumar:
    create table Employee ( empno number(3), name varchar2(10), deptno number(4))
    partition by range(deptno)
    (partition p1 values less than(11),
    partition p2 values less than(21),
    partition p3 values less than(31));
    create table Employee (
    ERROR at line 1:
    ORA-00439: feature not enabled: Partitioning
    Please help me for solving this problem and send me the details I need to partition my table.
    Thanks in advance.
    w.regards
    R.Satish <HR></BLOCKQUOTE>
    null

Maybe you are looking for

  • DTM for Mac and Tour OS 5.0

    I've been using a BB for 12 years but most of that time with DTM for Windows (until I saw the Mac light three years ago).  Since the BB DTM, (aside from the fact we Mac folks get very little RIM love), after I updated my Tour to the "official" Verizo

  • I did the iTunes update and now I am getting a Windows error 126 message.

    I did the iTunes update and now I am getting a Windows error 126 message. Now I can't use iTunes at all. Any ideas?

  • F4 help issue with Webdynpro ABAP application

    Hi, I am facing a strange issue with the F4 help in my webdynpro abap application. I have few fields for Purchase Order and Line item on the screen and they have corresponding F4 helps associated with them. When i select for F4 help, sometimes the sc

  • Need alot of help updating n800

    I have I have the old 2006 os version, and i cant update it with nokia updater. I tried it on four computers. It couldnt connect to the internet when i was on it, it said i didnt have the right time on my computer and i did, and on another computer i

  • Can not dowload in safari... HELP

    Hi, I want to download a .DMG-file but when I click the button "Download", the page will just refresh. When I use the CTRL of ALT-button on my Mac the will just download a .html file. Can somebody help me? I use the latest safari, java-updates. Thank