Oracle partitioning - change in existing tables

I recently started working with legacy code and noticed that some huge tables (5 years worth of data, don't have more details on me right now but can post later if needed) are partitioned based on time sequence number column while majority of queries are done based on time (different column). Queries performance is degrading over time and I'd like to try to modify partitioning and run some tests to see if there is a performance improvement.
My only concern is this is a lot of data and they are all live, so I have to come up with some sort of solution on how to switch partitioning with the least impact on applications running 24 x 7.
Can someone suggest a viable solution? Something you have done in the same situation and it worked?
If there is a certain technique on how to do it, please give me search keywords and I will google the rest.
Thanks,
S.

You can't change the partitioning of an existing table.
You can, however, use the DBMS_REDEFINITION package to do an online redefinition. Behind the scenes, what you're really doing is
- Creating a new table with the new partitioning scheme
- Copying the data from the old table to the new table
- Dropping the old table
- Renaming the new table to the name used by the old table
Now, if the large table is only being queried, not updated (or at least you have a window where it is read-only), it's probably easier to just do these steps manually rather than using DBMS_REDEFINITION where you at least have finer grained control over the steps. You'll still need a moment where the table is inaccessible to do the actual rename.
Justin

Similar Messages

  • Best way to change partition key on existing table

    Hi,
    Using Oracle 11.20.3 on AIX.
    We have a table about 800 million rows and 120gb in size.
    Want to try copies oif this table to evalaute different partitiong strategies.
    What is the quickest way to do this?
    Would have liked say datapump table 1 tro disk and datapumo import the data to new table but do the tables need to be of the same format.
    Thanks

    >
    Using Oracle 11.20.3 on AIX.
    We have a table about 800 million rows and 120gb in size.
    Want to try copies oif this table to evalaute different partitiong strategies.
    What is the quickest way to do this?
    Would have liked say datapump table 1 tro disk and datapumo import the data to new table but do the tables need to be of the same format.
    >
    First your subject asks a different question that the text you posted: Best way to change partition key on existing table. The answer to that question is YOU CAN'T. All data has to be moved to change the partition key since each partition/subpartition is in its own segment. You either create a new table or use DBMS_REDEFINITION to redefine the table online.
    Why do you want to export all data to a file first? That just adds to the time and cost of doing the op.
    What problem are you trying to use partitioning to solve? Performance? Data maintenance? For performance the appropriate partitioning key and whether to use subpartitions depends on the types of queries and the query predicates you typically use as well as the columns that may be suitable for partition keys.
    For maintenance a common method is to partition on a date by year/month/day so you can more easily load new daily/weekly/monthly data into its own partition or drop old data that no longer needs to be kept online.
    You should use a small subset of the data when testing your partitionings strategies.
    Can you do the partitioning offline in an outage window? If not then using the DBMS_REDEFINITION is your only option.
    Without knowing what you are trying to accomplish only general advice can be given. You even mentioned that you might want to use a different set of columns than the curren table has.
    A standard heap table uses ONE segment for its data (ignoring possible LOB segments). A partitioned/subpartitioned table uses ONE segment for each partition/subpartition. This means that ALL data must be moved to partition the table (unless you are only creating one partition).
    This means that every partitioning scheme that uses a different partition key requires ALL data to be moved again for that test.
    Provide some information about what problem you are trying to solve.
    >
    Is this quicker than datapump?
    >
    Yes - exporting the data simplying moves it all an additional time. Ok to export if you need a backup before you start.
    >
    Found artcle which talks about using merge option on datapump import to convert partitioned table to non-partitioned table.
    >
    How would that apply to you? That isn't what you said you wanted to do.

  • 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 add create partition to an existing table?

    hi,
    please tell me how to add partition to an existing table.
    i have tried
    alter table mvr add partition sno
    but getting error : ORA-14501: object is not partitioned
    thanks.

    Just Googling for ora-14501 resulted in the following
    Adding a partition results in ORA-14501: object is not partitioned
    It is really sad you can not do this on your own, and always need someone to do this for you.
    Sybrand Bakker
    Senior Oracle DBA

  • Can we addnew partition and sub partition in the existing table in one shor

    can we addnew partition and sub partition in the existing table in one short

    nav wrote:
    can we addnew partition and sub partition in the existing table in one shortYes,
    You can and below is the example for Range-List partition
    ALTER TABLE <table_name>
       ADD PARTITION <partition_name> VALUES LESS THAN (<value>
          STORAGE (INITIAL 20K NEXT 20K) TABLESPACE <TS name> NOLOGGING
              SUBPARTITION Clause
              SUBPARTITION Clause
              SUBPARTITION Clause
              SUBPARTITION Clause
               );

  • Logical type Partition of an existing table

    Dear All,
    My database is 10gR2 and Linux is the operating system.
    One of my table in production database is huge and contains lot of data. Table is growing on daily basis. There are many queries that users execute on this table and the criteria of selection is normally entry date of the record, its a field Entrty_Date with date datatype.
    I want logical partition on this table in such a way, that the table name remains the same, and data is partitioned logically.
    Like if the Entry_Date is starting from 2005, a partition is made on the criteria:
    2005-2006
    2006-2007
    2011When user query for records having entry date > 2011... the query is made only this chunk of the table, making the query fast.
    I hope I am able to make you understand my problem. If its possible in Oracle please let me know the name of the method and I will RND on this one. And I have to do it on existing table that contains lot of data.
    Thanks,
    Imran

    For example:
    CREATE TABLE sales
    ( prod_id NUMBER(6)
    , cust_id NUMBER
    , time_id DATE
    , channel_id CHAR(1)
    , promo_id NUMBER(6)
    , quantity_sold NUMBER(3)
    , amount_sold NUMBER(10,2)
    PARTITION BY RANGE (time_id)
    ( PARTITION sales_q1_2006 VALUES LESS THAN (TO_DATE('01-APR-2006','dd-MON-yyyy')) TABLESPACE tsa
    , PARTITION sales_q2_2006 VALUES LESS THAN (TO_DATE('01-JUL-2006','dd-MON-yyyy')) TABLESPACE tsb
    , PARTITION sales_q3_2006 VALUES LESS THAN (TO_DATE('01-OCT-2006','dd-MON-yyyy')) TABLESPACE tsc
    , PARTITION sales_q4_2006 VALUES LESS THAN (TO_DATE('01-JAN-2007','dd-MON-yyyy')) TABLESPACE tsd
    );

  • Can't stop oracle replication without affecting existing table...

    Hi All,
    I am facing some problem with oracle replication set up. I have a replication set up already running fine. There is a table called Emp_temp in the replication group which is in ASYNCHRONOUS mode(replicating data for every 15 min). My application is writing data into this table which is in primary server (there are only two servers in the set up i.e. primary and secondary).
    I want to stop the replication but my application should keep on writing to Emp_temp table even after replication stopped. But when I stopped the replication (through oemapp GUI) my application is throwing errors stating that it could not commit to that table. Can anyone tell me how to gracefully stop the replication? Is there any way even after stopping the replication application can continue writing to the Emp_temp table?
    My application talks to the Oracle using OCI.
    Error in my application log is: "Error ORA-23326: object group "PUBLIC"."ASYNCH" is quiesced"
    Oracle Version using: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    OS: Solaris 10
    Your early reply is highly appreciated
    Thanks in advance.
    Regards,
    Iqbal

    Hello
    Yes, breaking the PUSH job would be the only solution. In multimaster replication the changes are applied on the remote site through the PUSH job hence you should mark this job as BROKEN to stop the replication.
    If you QUIESCE (or SUSPEND) the replication group via OEM, then it would not allow any DML changes to the tables in the replication group. Hence you should break the PUSH job instead of SUSPENDing the Replication Group.
    Again, you should re-enable the PUSH job at the earliest else the base queues for replication would grow very fast in a high OLTP system. Once these queues have grown considerably then that could raise performance problems with the PUSH job.
    Hope this helps.
    Thanks,
    Rijesh

  • Partitioning an already existing table

    Hi,
    I need to partition many existing tables. All these tables hold more than 50 million data each.
    Since i am new to partitioning, can any one kindly guide what are the best practices one should look for under such circumstances.
    Is it neccessary to dwell on the following point
    1) Type of table (Heap or IOT etc).
    2) Indexes and kinds of indexes along with the columns in which they are defined.
    3) Block size
    4) Constraints
    5) Row Chaining, Migration etc.
    I have very basic idea about the above mentioned points.
    Please guide me as to how should the partitioning be done, what sort of partitioning is best, any performace issues.
    I sincerely appreciate the cooperation of all members.
    Thanks in advance
    Message was edited by:
    Master

    Hi,
    to create a partitioned table from the non portioned table
    create table part partition XXXXXXXX
    (partition p01 tablespace XX1,
    partition p02 tablespace XX2,
    partition p03 tablespace XX3,
    partition p04 tablespace XX 4
    nologging
    as select * from old data ;
    OR
    export the old non partition table data – rename the non partitioned table, create partitioned table import the data
    OR
    Exchanging Partitions
    You can convert a partition (or sub partition) into a non-partitioned table, and a non-partitioned table into a partition (or sub partition) of a partitioned table by exchanging their data segments. You can also convert a hash-partitioned table into a partition of a range-hash partitioned table, or convert the partition of the range-hash partitioned table into a hash-partitioned table. Similarly, you can convert a list-partitioned table into a partition of a range-list partitioned table, or convert the partition of the range-list partitioned table into a list-partitioned table
    One of the great features about partitioning, and most specifically range-based partitioning, is the ability to load in new data quickly and easily with minimal impact on the current users. The manuals indicate that the critical command to achieve this is as follows:
    alter table pt_tab1 exchange partition p_9999
    with table new_data
    Ani

  • How to add partition to an existing table

    I have a table that contains lot of data.I need to add partitions to it to improve the performance of the procedures
    using this table.This table is having no existing partition.

    create partitioned table and move your data into. You can't create partitions based on common heap-table.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/partconc.htm#CNCPT011

  • HOW to enable oracle advance compression for EXIST partitioned table

    Hi All,
    I have to enable oracle advance compression for existing table which PARTITION BY RANGE then SUBPARTITION BY HASH.
    ORacle version: 11.2.0.2.0
    Please provide me any relevant doc or any exp.
    Thanks in advance.

    could not see any text for how to enable oracle advance compression for EXIST partitioned table.RTFM.
    From the resource above:
    How do I compress an existing table?
    There are multiple options available to compress existing tables. For offline compression, one could use ALTER TABLE Table_Name MOVE COMPRESS statement. A compressed copy of an existing table can be created by using CREATE TABLE Table_Name COMPRESS FOR ALL OPERATIONS AS SELECT *. For online compression, Oracle’s online redefinition utility can be used. More details for online redefinition are available here.
    "

  • Partitioning an Existing Table

    Dear Forum,
    Can we create partition on an existing table without dropping it in Oracle 11.2.0.3.0?
    I know EXCHANGE PARTITION, but that I don't want.
    Thank you & regards.

    You cannot partition an existing table.
    You have to create a new partitioned table and move the data from the old table to the new table. If you want to do this online, you can potentially leverage the DBMS_REDEFINITION package to help you out. Behind the scenes, you're still creating a new table and, eventually, dropping the old table after moving all the data over. DBMS_REDEFINITION hides some of that from you and lets the table remain online while you are moving the data. But it adds some performance overhead.
    Justin

  • ORA-14402: updating partition key column would cause a partition change

    Hi,
    When I am trying to execute an update statement where i am tring to update date values emp_det from 11-oct-2010 to 12-nov-2010.
    Oracle throws an error :
    ORA-14402
    updating partition key column would cause a partition change
    I think that this is because emp_det is a partitioning key of a partitioned table.
    Oracle documentation says that
    "UPDATE will fail if you change a value in the column that would move the
    row to a different partition or subpartition, unless you enable row
    movement" .
    alter table t enable row movement;
    I did not understand what is meant by "enable row movement".
    I cannot drop the partitions and recreate it after updating the table and also i don't have proper priviliges for enale row movement syntax
    because of the lack of privileges. How to solve this is issues with out row movement and recreate partition.
    Can this be done by a developer or is there any other way to execute update in this case? its urgent.. pls help..
    thanks in advance..
    By
    Sivaraman
    Edited by: kn_sivaraman on Nov 1, 2010 2:32 AM

    kn_sivaraman wrote:
    I did not understand what is meant by "enable row movement". Each partition in partitioned table is physically separate segment. Assume you have a row that belongs to partition A stored in segment A and you change row's partitioning column to value that belongs to partition B - you have an issue since updated row can't be now stored in segment A anymore. By default such update is not allowed and you get an error. You can enable row movement and Oracle will move row to target partition:
    SQL> CREATE TABLE SALES_LIST(
      2                          SALESMAN_ID NUMBER(5,0),
      3                          SALESMAN_NAME VARCHAR2(30),
      4                          SALES_STATE VARCHAR2(20),
      5                          SALES_AMOUNT NUMBER(10,0),
      6                          SALES_DATE DATE
      7                         )
      8    PARTITION BY LIST(SALES_STATE)
      9    (
    10     PARTITION SALES_WEST     VALUES('California', 'Hawaii'),
    11     PARTITION SALES_EAST     VALUES('New York', 'Virginia', 'Florida'),
    12     PARTITION SALES_CENTRAL  VALUES('Texas', 'Illinois'),
    13     PARTITION SALES_OTHER    VALUES(DEFAULT)
    14    )
    15  /
    Table created.
    SQL> insert
      2    into sales_list
      3    values(
      4           1,
      5           'Sam',
      6           'Texas',
      7           1000,
      8           sysdate
      9          )
    10  /
    1 row created.
    SQL> update sales_list
      2    set  sales_state = 'New York'
      3    where sales_state = 'Texas'
      4  /
    update sales_list
    ERROR at line 1:
    ORA-14402: updating partition key column would cause a partition change
    SQL> alter table sales_list enable row movement
      2  /
    Table altered.
    SQL> update sales_list
      2    set  sales_state = 'New York'
      3    where sales_state = 'Texas'
      4  /
    1 row updated.
    SQL> SY.

  • How to create partition after creating the table

    I have created a table. Now I want to create range partitions of that table.Please tell me how to do this?

    Yes, that is true.
    It is also possible to create a new partitioned table with exactly the same structure, ensure it has a partition, and exchange (trade) the partition for that existing table. That is outlined in the DBA manual at http://tahiti.oracle.com under chapter 17 "Managing Partitioned Tables and Indexes" close to the keywords 'exchange' or 'convert'

  • How to change the partition type on a table with data

    Hi
    I have a table, which is partitioned by list on date column. The table contains large volume of data.
    My requirement is to make the list partition into range on the same date column.
    I am working on Oracle10g
    Kindly advice

    partitioned by list on date How many distinct DATE values do you have ? Each DATE value would be a Partition in List Partitioning.
    Why do you need to convert this to RANGE Partitioning ? How many DATE values do you expect in the table in the future ?
    You can use DBMS_REDIFINITION to copy a LIST Partitioned Table to a RANGE Partitioned Table and then switch the tables at the end.
    See examples (where the source table is not partitioned)
    http://www.oracle-base.com/articles/misc/partitioning-an-existing-table.php
    http://uhesse.com/2010/02/15/partitioning-a-table-online-with-dbms_redefinition/
    But before converting I would justify why a LIST Partitioned Table be converted to RANGE Partitioned. Do you have Date-Range queries ?
    Hemant K Chitale
    Edited by: Hemant K Chitale on Mar 15, 2013 2:11 PM

  • Oracle 11g imp erroneously tries to recreate existing tables with CLOBs?

    I have a shell script for loading database dumps from both Datapump and the older exp/imp.
    Often when loading dumps, I need to rename the schema owner and tablespace names (which is handled by REMAP_SCHEMA and REMAP_TABLESPACE in Datapump).
    However I have a whole bunch of dumps created with exp at this point and not that many Datapump dumps yet. As such the old style dumps are handled by the shell script in this way:
    1) A first pass imp is run using INDEXFILE to generate a file with the SQL to create tables and indexes. Options also include FROMUSER and TOUSER.
    2) A series of sed command edit the SQL file to change the tablespace names (which are schema owner specific in our case).
    3) The editted SQL file is run with sqlplus to create the tables and indexes.
    4) A second pass imp is run to load the table rows as well as triggers, stored procedures, views, etc. Options include FROMUSER, TOUSER, COMMIT=Y, IGNORE=Y, BUFFER, STATISTICS=NONE, CONSTRAINTS=N
    This shell script has been working great for loading exp dump files into Oracle 9 and Oracle 10 databases, but now that I'm trying to load these dumps into Oracle 11, it fails.
    The problem is in step 4, the imp program is trying to create some of the tables that already were created with sqlplus in step 2. The problematic tables all seem to have CLOB columns in them. The table creation fails because it tries to use the tablespace names from the dump file, which do not exist in the destination database. And when the table creation fails, imp then decides not to load the rows for those table.
    This seems like a bug in the Oracle 11 imp program. I don't understand why it thinks it needs to recreate tables that already exist when those tables have CLOB columns. Is there something different about CLOB columns in Oracle 11 that I should know about that might be confusing imp into thinking that it needs to create tables when they already exist? Maybe I need to do something to those tables in SQL so that imp does not think it needs to recreate them?
    I know that the tables with the CLOBs were created correctly because I was trying to find some way to workaround this. For step 4, I tried using DATA_ONLY=Y, in which case imp does not try to create the tables and just loads the table rows. Of course using DATA_ONLY, I don't get a lot of other things like triggers, view and stored procedures. I started to try to get around that by doing 3 passes with imp, so that I could pick up the missing pieces by using an imp pass with ROWS=N, but strangely that has the same problem of trying to recreate the existing tables.

    The only solution I've found so far as a workaround is rather convoluted.
    1. I took an export using datapump's expdp of SCHEMA1 (in 10g it will skip the table with the xmltype).
    2. I imported the data to my empty schema (SCHEMA2) using impdp. To avoid the error that the type already exists with another OID, I used the TRANSFORM=oid:n parameter e.g.
    impdp user/pwd dumpfile=noxmltable.dmp logfile=importallbutxmltable.log remap_schema=SCHEMA1:SCHEMA2 TRANSFORM=oid:n directory=MYDUMPDIR
    3. I then manually created my xmltype table in the SCHEMA2 and did a select into to load it (make sure you have the select privileges to do so):
    INSERT INTO SCHEMA2.XMLTABLE2 SELECT * FROM SCHEMA1.XMLTABLE1;
    4. I am still taking an export with exp of the xmltable as well even though I'm not sure I can do anything with it.
    Thanks!
    Edited by: stacyz on Jul 28, 2009 9:49 AM

Maybe you are looking for

  • OSB 10.3.1 Outbound File Adapter

    Hi, We have a requirement like, the service will receive an attachment (excel sheet and pdf files) file and store that file in the server. We have created a business service of Messaging service with input as binary and out as none, and we are invoki

  • Notification center tweet function 140 character bug

    Hi, I have noticed a minor issue with the Notification Center 'tweet' function. It doesn't seem possible to send a 140-character message. If you use all 140 characters, and try to send the message, it reports a Twitter connection failure. I have only

  • DMS to HR Department

    Dear All, Kindly let me know, if we can bring the HR Master Records to DMS Object Links. Regards, Ravi B

  • Selecting a Role from dropdown list throws error

    Hi, I'm using CRM Web UI 7.0. I'm facing problem selecting a Role from dropdown list in the assignment block Roles in the screen Employee. The problem is that the dropdown list doesn't show any value on clicking and gives an error message "Error on p

  • Modal JInternal Frames?

    Is there a possibility to create REAL custom modal JInternalFrames? I mean without using JOptionPane.showInternal.. since these cannot be customized in size, and dont return a reference. felix