TTS or Exchange Partitions -- Opinion needed

Hi All,
So i have two tables with the same structure, with the same partition key and they are both partitioned hourly, but they reside in two different databases (one of them is actually a datawarehouse).
We have a requirement to move data from one database to another and were researching on the fastest method to accomplish this. I was thinking of two possibilities:-
1) Exchange Partitions.
2) Transportable Tablespaces.
Can you please advise on what is the best method to accomplish this? And why?
Thanks

These are neither SQL or PL/SQL related question - I suggest that you ask this in the [url http://forums.oracle.com/forums/forum.jspa?forumID=61]Database - General forum instead. It deals with general database and database administration questions.

Similar Messages

  • Oracle TTS or Exchange Partitions -- Opinions?

    Hi All,
    So i have two tables with the same structure, with the same partition key and they are both partitioned hourly, but they reside in two different databases (one of them is actually a datawarehouse).
    We have a requirement to move data from one database to another and were researching on the fastest method to accomplish this. I was thinking of two possibilities:-
    1) Exchange Partitions.
    2) Transportable Tablespaces.
    And one of my main requirement is that both these tables must be available always. I cant take any tablespaces offline.
    Can you please advise on what is the best method to accomplish this? And why?
    Thanks

    These are neither SQL or PL/SQL related question - I suggest that you ask this in the [url http://forums.oracle.com/forums/forum.jspa?forumID=61]Database - General forum instead. It deals with general database and database administration questions.

  • Exchange Partition

    Hi,
    What happens when :
    1. A query is running on a partition table has millions of records.
    2. Alter table exchange partition ... issued
    Does it completes step (1) first and than it takes (2)step or how it handles? Or will it show wrong result in the query? Please help.

    I have a case for the need to exchange partitions between two range partitioned tables. For example table SALES_HIST contains millions of sales records from the last 5 years range partitioned by fiscal year and month.
    The need arises to add new columns to the table for the current year and going forward. The new columns are meaningless to prior years so the decision is made to move data older than the prior year to separate tables which should retain the fiscal year/month partitioning for performance.
    If we had the ability to exchange partitions between partitioned tables, this would be a simple matter of a series of DDL statements to create the new table(s) and index(es) and then exchange partitions from the current table to the new table. Instead, we are forced to create the table, insert into NEW_TAB /*+ append */ select * from SALES_HIST, alter table sales_hist drop partition, create indexes on new_tab; repeat ad nauseum. And, since the volume of data is huge, we are forced to insert piecemeal else we blow out temp space and drag the system to a crawl.

  • How to use Exchange partition

    Hi All,
    I have a requirement like .. i have to insert the data from partition table to unpartition table like temp table. by googling i came to know about Exchange partition. by using Exchange partition we can dump temp table to partition table but i don't know how to copy the data from partition table to temp table. following script am using.
    ALTER TABLE abc_partition
    EXCHANGE PARTITION P_2011_1115 WITH TABLE abc_tmp
    INCLUDING INDEXES
    WITHOUT VALIDATION;
    And again i have created a partition table and i ran below query
    ALTER TABLE abc_tmp
    EXCHANGE PARTITION P_2011_1115 WITH TABLE abc_partition
    INCLUDING INDEXES
    WITHOUT VALIDATION;
    but i was getting an error like partition ALTER TABLE EXCHANGE requires a non-partitioned, non-clustered table
    Thanks
    Sree
    Edited by: 874823 on Apr 30, 2012 2:01 AM

    In that case, you need to follow these basic steps.
    1. Use a CTAS (Create Table as Select) to create the staging table. This table's structure needs to match that of the partition table - be that a hash or index organised structure. The columns need to be in the same order, and of the same data type. Not null constraints need to be applied to the applicable columns. If you have manually set storage clauses (e.g. PCTFREE for example) for the partition table, the same needs to be applied to the staging table.
    A CTAS would look something as follows:
    create table staging_table(
      col1 not null,
      col2 null,
      col3 null
    ) nologging as
    select
      some_col,
      some_other_column,
      third_column
    from some_other_data2. The next step is to add the required indexes to the staging table - as that table needs to match the structure of the partitioned table. So the staging table needs to have the same index structures as local partition indexes of the partition table.
    3. The actual partition exchange can now happen. The data is not actually exchanged. Ownership of the data changes. The data blocks (for data and indexes) owned by the staging table, is now owned by that partition in the partition table. Likewise the staging table now owns the data and indexes of the partition.
    4. The last step is cleaning up - dropping and purging the staging table (assuming that you no longer have a need for it).
    The above steps can be fully automated (for any partition table) by developing a generic PL/SQL interface library that performs these steps. Additional features such as parallel processing and tablespaces to use for the staging table and indexes can also considered for such a PL/SQL interface.

  • Exchange Partition on large Partition tables in dataware house

    Hi all,
    oracle 10.2.0.4(64 bit) and OS 5.3 (64 bit).
    We have large tables in our DWH size in TB and data is for 13 Months.
    Now our management want to split these tables in two.
    current tables contain data for 3 months and current month and history tables contain data for history data of 9 months.
    We have no space on mount point for export/import.
    Can exchange partition will work on it? if yes, please need steps/demo/examples.
    Some partitions has size more then 300gb.

    user610482 wrote:
    Hi Oracle gurus,
    I need a dynamic script to add MAXVALUE partition to all 100 tables in schema,each tables are having different Partition Key with different tablespace
    AVB1_NOTIFICATIONSL have 2 columns in partition key
    For eg : alter table AVB1_NOTIFICATIONSL add partition DMAX VALUES LESS THAN (MAXVALUE,MAXVALUE) TABLESPACE LARGE_D
    is SQL above valid?
    does it do what you require?

  • Problem exchanging partitions using range partitioning

    I have a range-partitioned table. Here's a cut down version....
    CREATE TABLE MY_TABLE
       (     VALUE           NUMBER,
         PARTITION_KEY      NUMBER
      PARTITION BY RANGE ("PARTITION_KEY")
    (PARTITION "P1"  VALUES LESS THAN (2),
      PARTITION "P2"  VALUES LESS THAN (3),
      PARTITION "P3"  VALUES LESS THAN (4),
      PARTITION "P4"  VALUES LESS THAN (5),
      PARTITION "P5"  VALUES LESS THAN (6),
      PARTITION "P6"  VALUES LESS THAN (7),
      PARTITION "P7"  VALUES LESS THAN (8));For the process I'm working on, I want to be able to:
    - create a table as a copy of one of the partitions
    - do some processing on that table
    - exchange the updated table back into the partitioned table
    I can achieve this as follows....
    CREATE TABLE MY_TABLE_COPY_P7 AS (SELECT * FROM MY_TABLE WHERE PARTITION_KEY = 7);
    ... do processing ...
    ALTER TABLE MY_TABLE DROP PARTITION P7;
    ALTER TABLE MY_TABLE ADD PARTITION P7 VALUES LESS THAN (8);
    ALTER TABLE MY_TABLE EXCHANGE PARTITION P7 WITH TABLE MY_TABLE_COPY INCLUDING INDEXES;However, this only works if the partition I'm adding back in is the highest partition.
    If I try do take out one of the middle partitions, then add it back I get an error:
    SQL] ALTER TABLE MY_TABLE ADD PARTITION P5 VALUES LESS THAN (6);
    ALTER TABLE MY_TABLE ADD PARTITION P5 VALUES LESS THAN (6)
    ERROR at line 1:
    ORA-14074: partition bound must collate higher than that of the last partitionAny ideas on how I can exchange one of the middle partitions with having to first drop the higher ones?
    Btw, I have to use range partitioning as we're using spatial, which only supports range partitioning.
    Cheers,

    Actually, you can do the exchange partition thing with 8i and over. After creating my_table from your script, I did:
    SQL> INSERT INTO my_table VALUES (1,7.5);
    1 row created.
    SQL> INSERT INTO my_table VALUES (2, 7.2);
    1 row created.
    SQL> INSERT INTO my_table VALUES (3,7.7);
    1 row created.
    SQL> CREATE TABLE my_tab_tmp AS
      2  SELECT * FROM my_table
      3  WHERE 1=2;
    Table created.
    SQL> ALTER TABLE my_table EXCHANGE PARTITION P7 WITH TABLE my_tab_tmp;
    Table altered.
    SQL> SELECT * FROM my_tab_tmp;
         VALUE PARTITION_KEY
             1           7.5
             2           7.2
             3           7.7
    SQL> SELECT * FROM my_table;
    no rows selected
    SQL> UPDATE my_tab_tmp
      2  set value = value * 20;
    3 rows updated.
    SQL> COMMIT;
    Commit complete.
    SQL> ALTER TABLE my_table EXCHANGE PARTITION P7 WITH TABLE my_tab_tmp;
    Table altered.
    SQL> SELECT * FROM my_tab_tmp;
    no rows selected
    SQL> SELECT * FROM my_table;
         VALUE PARTITION_KEY
            20           7.5
            40           7.2
            60           7.7You will, of course, need to re-build any global indexes on my_table.
    When you first create my_tab_tmp, you should also create indexes to match any local indexes on the partitions, then do the exchange partition using the INCLUDING INDEXES clause. You could also skip creating the indexes and then re-create them after exchanging the updated table with the partition.
    Note that none of this will work if you are changing values of partition_key so thatthey fall out of the range for the partition.
    HTH
    John

  • Trying to convert Interval Partitioned Table to Range..Exchange Partition..

    Requirement:
    Replace Interval partitioned Table by Range Partitioned Table
    DROP TABLE A;
    CREATE TABLE A
       a              NUMBER,
       CreationDate   DATE
    PARTITION BY RANGE (CreationDate)
       INTERVAL ( NUMTODSINTERVAL (30, 'DAY') )
       (PARTITION P_FIRST
           VALUES LESS THAN (TIMESTAMP ' 2001-01-01 00:00:00'));
    INSERT INTO A
         VALUES (1, SYSDATE);
    INSERT INTO A
         VALUES (1, SYSDATE - 30);
    INSERT INTO A
         VALUES (1, SYSDATE - 60);I need to change this Interval Partitioned Table to a Range Partitioned Table. Can I do it using EXCHANGE PARTITION. As if I use the conventional way of creating another Range Partitioned table and then :
    DROP TABLE A_Range
    CREATE TABLE A_Range
    a NUMBER,
    CreationDate DATE
    PARTITION BY RANGE (CreationDate)
       (partition MAX values less than (MAXVALUE));
    Insert  /*+ append */  into A_Range Select * from A; --This Step takes very very long..Trying to cut it short using Exchange Partition.Problems:
    I can't do
    ALTER TABLE A_Range
      EXCHANGE PARTITION MAX
      WITH TABLE A
      WITHOUT VALIDATION;
    ORA-14095: ALTER TABLE EXCHANGE requires a non-partitioned, non-clustered table
    This is because both the tables are partitioned. So it does not allow me.
    If I do instead :
    create a non partitioned table for exchanging the data through partition.
      Create Table A_Temp as Select * from A;
       ALTER TABLE A_Range
      EXCHANGE PARTITION MAX
      WITH TABLE A_TEMP
      WITHOUT VALIDATION;
      select count(*) from A_Range partition(MAX);
    -Problem is that all the data goes into MAX Partition.
    Even after creating a lot of partitions by Splitting Partitions, still the data is in MAX Partition only.
    So:
    -- Is it that we can't Replace an Interval Partitioned Table by Range Partitioned Table using EXCHANGE PARTITION. i.e. We will have to do Insert into..
    -- We can do it but I am missing something over here.
    -- If all the data is in MAX Partition because of "WITHOUT VALIDATION" , can we make it be redistributed in the right kind of range partitions.

    You will need to pre-create the partitions in a_range, then exchange them one by one from a to a tmp then then to arange. Using your sample (thanks for proviing the code by the way).
    SQL> CREATE TABLE A
      2  (
      3     a              NUMBER,
      4     CreationDate   DATE
      5  )
      6  PARTITION BY RANGE (CreationDate)
      7     INTERVAL ( NUMTODSINTERVAL (30, 'DAY') )
      8     (PARTITION P_FIRST
      9         VALUES LESS THAN (TIMESTAMP ' 2001-01-01 00:00:00'));
    Table created.
    SQL> INSERT INTO A VALUES (1, SYSDATE);
    1 row created.
    SQL> INSERT INTO A VALUES (1, SYSDATE - 30);
    1 row created.
    SQL> INSERT INTO A VALUES (1, SYSDATE - 60);
    1 row created.
    SQL> commit;
    Commit complete.You can find the existing partitions form a using:
    SQL> select table_name, partition_name, high_value
      2  from user_tab_partitions
      3  where table_name = 'A';
    TABLE_NAME PARTITION_NAME HIGH_VALUE
    A          P_FIRST        TO_DATE(' 2001-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
    A          SYS_P44        TO_DATE(' 2013-01-28 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
    A          SYS_P45        TO_DATE(' 2012-12-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
    A          SYS_P46        TO_DATE(' 2012-11-29 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAYou can then create table a_range with the apporopriate partitions. Note that you may need to create additional partitions in a_range because interval partitioning does not create partitions that it has no data for, even if that leaves "holes" in the partitioning scheme. So, based on the above:
    SQL> CREATE TABLE A_Range (
      2     a NUMBER,
      3     CreationDate DATE)
      4  PARTITION BY RANGE (CreationDate)
      5     (partition Nov_2012 values less than (to_date('30-nov-2012', 'dd-mon-yyyy')),
      6      partition Dec_2012 values less than (to_date('31-dec-2012', 'dd-mon-yyyy')),
      7      partition Jan_2013 values less than (to_date('31-jan-2013', 'dd-mon-yyyy')),
      8      partition MAX values less than (MAXVALUE));
    Table created.Now, create a plain table to use in the exchanges:
    SQL> CREATE TABLE A_tmp (
      2     a              NUMBER,
      3     CreationDate   DATE);
    Table created.and exchange all of the partitions:
    SQL> ALTER TABLE A
      2    EXCHANGE PARTITION sys_p44
      3    WITH TABLE A_tmp;
    Table altered.
    SQL> ALTER TABLE A_Range
      2    EXCHANGE PARTITION jan_2013
      3    WITH TABLE A_tmp;
    Table altered.
    SQL> ALTER TABLE A
      2    EXCHANGE PARTITION sys_p45
      3    WITH TABLE A_tmp;
    Table altered.
    SQL> ALTER TABLE A_Range
      2    EXCHANGE PARTITION dec_2012
      3    WITH TABLE A_tmp;
    Table altered.
    SQL> ALTER TABLE A
      2    EXCHANGE PARTITION sys_p46
      3    WITH TABLE A_tmp;
    Table altered.
    SQL> ALTER TABLE A_Range
      2    EXCHANGE PARTITION nov_2012
      3    WITH TABLE A_tmp;
    Table altered.
    SQL> select * from a;
    no rows selected
    SQL> select * from a_range;
             A CREATIOND
             1 23-NOV-12
             1 23-DEC-12
             1 22-JAN-13John

  • Disk Utility - Partition map needs repair because a data partition needs loader space.

    I just finished setting up both my OSX and Windows installs from scratch after fitting an SSD, which in-turn was right before my logic board died and Apple replaced it, now it looks like I have some sort of hard drive issue brewing.
    This was my plan for the SSD, and how it currently displays in Disk Utility although that wasn't the case earlier:
    And in Terminal:
    My intention was to have two boot partitions for each OS, 'Macintosh HD' and 'Win 7 Pro' and a third shared data partition 'Projects' on the SSD, which I made in Drive Genius after installing Boot Camp. I don't want Macintosh HD accessible from Windows because I'll be using Paragon HFS+ or MacDrive to give write access and don't want OSs stomping on other OSs turf, hence needing three partitions. Everything looked fine until I just checked Disk Management under windows and realised it couldn't see the Projects volume. Even though it's fine in OS X, it was just marked black/unallocated space.
    So I booted back into OSX, all my files look fine so I ran Disk Utility and the Partition tab looked really odd - unfortunately I didn't get a screenshot. All volumes reported their size correctly but visually, Macintosh HD took up most of the drive. I could see 'Windows 7 Pro' under this, but the Partition Layout section had a scrollbar, which if I scrolled down showed 'Projects' squished into a tiny gap at the bottom. I ran a Verify, which reported no problems, and at some time since the Partition Layout has reverted to how it should look (as in the screenshot above), with 'Projects' book-ended by "Macintosh HD' and 'Windows 7 Pro'.
    Now when I run a Verify on Macintosh HD or Projects volumes, it says there's no problem, but if I run one on the drive, I get this message:
    Volume Macintosh HD on disk0s2 has 0 bytes of trailing loader space and it needs 134217728 bytes
    Problems were found with the partition map which might prevent booting
    Error: Partition map needs repair because a data partition needs loader space.
    I've only managed to find one other mention of this error here, but the fix is not relevant to me because I don't have Sophos installed. I've tried Single User/Safe Mode but it just boots into normal mode, so I can't do a fsck -fy.
    ** /dev/rdisk0s2 (NO WRITE)
    Can't open /dev/rdisk0s2: Permission denied
    That value in bytes is exactly 128mb, so I suspect the problem lies with one of the invisible partitions that show up in iPartition and Disk Management under Windows, but not in Disk Utility. I have backups and I suspect the root of the problem is partitioning in iPartition after installing Boot Camp, but I've never had issues with this approach in the past so I'm wary of just giving up and reinstalling Windows again will be massive hassle because I no longer have a SuperDrive and last time it refused to install from USB.
    Anyone have any idea what's going on? It seems like the sort of issue Disk Utility should just handle, at least in Recovery mode, but it's not playing ball. It also doesn't seem like a massive problem since my files all look fine and performance is OK, so I'm reluctant to do anything major.
    I'll update with a shot of the drive in Disk Management from Windows in a few minutes, in case that sheds light on anything. Thanks!

    Similar issue here. I manually partitioned my hard disk for triple boot (using Gparted on Linux), then everything was just fine until I ran bootcamp, to do something as simple as create a boot USB.
    I get the same error as a result and have to work my way into booting, by resorting first to a Linux live USB, then restarting from the live USB, to finally reach my rEFInd boot manager, or whichever boot manager should be initialized at startup.
    I suppose that the cause in my case is that some operation "scratched" the protective MBR. See this:
    http://www.mactech.com/articles/mactech/Vol.23/23.03/APMtoGPT/index.html
    I am hoping to fix it using an external Yosemite installation media: see this guide -
    http://www.macworld.com/article/2367748/how-to-make-a-bootable-os-x-10-10-yosemi te-install-drive.html
    And as a last resort to reinstall.
    I'll admit I am negatively surprised. I need this computer for professional reasons, and for the sake of "preserving the integrity of OSX", measures defined by Apple instead tend to make partitions far easier to damage. And this problem seems to affect a number of users.
    As for what I have to go through to fix it: a 5GB download, during which I have to register my credit card to the Apple Store. "Pay first, get your free software next."
    IF Disk Utility can fix it, from the external media, then fair enough. The hassle is unpleasant but it files as "a choice".
    Otherwise you can file it safely under software design calamity.

  • MacBookPro SSD Error- ALERT: The partition map needs to be repaired because there's a problem with the EFI system partition's file system.

    MacBook Pro OS x Mavericks. I have Sandisk 256GB SSD and I am getting a below error message.
    ALERT: The partition map needs to be repaired because there's a problem with the EFI system partition's file system.
    Does anyone know how to resolve this error and fix it ? unfortunately I don't have a Time Machine backup. Thanks!

    Have you tried to run the verify/repair permissions and verify/repair disk through the recovery disk? If that didn't work then I would reinstall the OS after backing up. If that still doesn't work I would take it in.

  • Materialized view on a Partitioned Table (Data through Exchange Partition)

    Hello,
    We have a scenario to create a MV on a Partitioned Table which get data through Exchange Partition strategy. Obviously, with exchange partition snap shot logs are not updated and FAST refreshes are not possible. Also, this partitioned table being a 450 million rows, COMPLETE refresh is not an option for us.
    I would like to know the alternatives for this approach,
    Any suggestions would be appreciated,
    thank you

    From your post it seems that you are trying to create a fast refresh view (as you are creating MV log). There are limitations on fast refresh which is documented in the oracle documentation.
    http://docs.oracle.com/cd/B28359_01/server.111/b28313/basicmv.htm#i1007028
    If you are not planning to do a fast refresh then as already mentioned by Solomon it is a valid approach used in multiple scenarios.
    Thanks,
    Jayadeep

  • Oracle Exchange partition feature not working as expected?

    I used the Exchange Partition feature to swap segments between 2 tables- one Partitioned, and one Non-Partitioned. The exchange went well. However, all the data in the partitioned table has gone to the partition which stores the maxbound values.
    Any ideas if this is the default behavior or have i missed out something?
    /** actual table names changed due to client confidentiality issues */
    -- Drop the 2 intermediate tables if they already exist
    drop table ordered_inv_bkp cascade constraints ;
    drop table ordered_inv_t cascade constraints ;
    1st create a Non-Partitioned Table from ORDERED_INV and then add the primary key and unique index(s):
    create table ordered_inv_bkp as select * from ordered_inv ;
    alter table ordered_inv_bkp add constraint ordinvb_pk primary key (ordinv_id) ;
    create unique index ordinv_scinv_uix on ordered_inv_bkp(
    SCP_ID ASC,
    INV_ID ASC,
    ANATLOC_ID ASC,
    SOI_ID ASC,
    CANCEL_TS ASC );
    -- Next, we have to create a partitioned table ORDERED_INV_T with a similar
    -- structure as ORDERED_INV.
    -- This is a bit tricky, and involves a pl/sql code
    declare
    l_dt_start DATE;
    l_ptn VARCHAR2(50);
    cnt PLS_INTEGER;
    l_cnt_initial PLS_INTEGER;
    ts_name VARCHAR2(50);
    l_sql VARCHAR2(10000);
    ts_indx VARCHAR2(100);
    l_num_errors NUMBER ;
    l_num_errors_ok NUMBER ;
    l_user_name VARCHAR2(50) ;
    l_sysdate VARCHAR2(50);
    l_cnt_script PLS_INTEGER ;
    BEGIN
    SELECT COUNT(*) INTO cnt FROM user_TABLES
    WHERE TABLE_NAME='ORDERED_INV_T';
    IF cnt=0 THEN
    l_sql:= 'CREATE TABLE ORDERED_INV_T
    PARTITION BY RANGE (ORDINV_TIME)
    ( PARTITION TP_ORDINV_MAX VALUES LESS THAN (MAXVALUE)
    TABLESPACE TEST_TPT_DATA
    ENABLE ROW MOVEMENT
    AS SELECT * FROM ORDERED_INV WHERE 1=0 ';
    EXECUTE IMMEDIATE l_sql;
    -- Add section to set default values for the intermediate table OL_ORDERED_INV_T
    FOR crec_cols IN (
    SELECT u.column_name ,u.nullable, u.data_default,u.table_name
    FROM USER_TAB_COLUMNS u WHERE
    u.table_name ='ORDERED_INV' AND
    u.data_default IS NOT NULL )
    LOOP
    l_sql:= 'ALTER TABLE ORDERED_INV_T MODIFY '||crec_cols.column_name||' DEFAULT '||crec_cols.data_default;
    -- dbms_output.put_line('chk data default => ' || l_sql) ;
    EXECUTE IMMEDIATE l_sql;
    END LOOP;
    END IF;
    -- Split partition to create more partitions
    select TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') into l_sysdate from dual;
    DBMS_OUTPUT.PUT_LINE ('Finding oldest value at ' || l_sysdate) ;
    EXECUTE IMMEDIATE 'SELECT NVL(TRUNC(MIN(OL_ORDINV_TIME),''MONTH''),TRUNC(SYSDATE,''MONTH''))
    FROM ORDERED_INV' INTO l_dt_start;
    select TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS') into l_sysdate from dual;
    DBMS_OUTPUT.PUT_LINE ('Started creating partitions at ' || l_sysdate) ;
    LOOP
    EXIT WHEN l_dt_start > ADD_MONTHS(TRUNC(SYSDATE,'MONTH'),1);
    l_ptn:='tp_ordinv_'|| TO_CHAR(l_dt_start,'YYYYMM');
    l_sql:= 'ALTER TABLE ORDERED_INV_T
    split partition TP_ORDINV_MAX at (TO_DATE('''|| TO_CHAR(ADD_MONTHS(l_dt_start,12),'YYYYMM') ||''',''YYYYMM''))
    into ( partition '||l_ptn||' , partition TP_ORDINV_MAX)';
    execute immediate l_sql;
    l_dt_start:=add_months(l_dt_start,12);
    END LOOP;
    END;
    -- Also, add indexes to this table
    alter table ORDERED_INV_T add constraint ordinvt_pk primary key (ordinv_id) ;
    create unique index ordinvt_uix on ordered_inv_t(
    SCP_ID ASC,
    INV_ID ASC,
    ANATLOC_ID ASC,
    SOI_ID ASC,
    CANCEL_TS ASC );
    -- Next, use exchange partition for actual swipe
    -- Between ordered_inv_t and ordered_inv_bkp
    -- Analyze both tables : ordered_inv_t and ordered_inv_bkp
    BEGIN
    DBMS_STATS.GATHER_TABLE_STATS(OWNNAME => 'HENRY220', TABNAME => 'ORDERED_INV_T');
    DBMS_STATS.GATHER_TABLE_STATS(OWNNAME => 'HENRY220', TABNAME =>'ORDERED_INV_BKP');
    END;
    SET TIMING ON;
    ALTER TABLE ordered_inv_t
    EXCHANGE PARTITION TP_ORDINV_MAX
    WITH TABLE ordered_inv_bkp
    WITHOUT VALIDATION
    UPDATE GLOBAL INDEXES;
    -- Check query :
    select partition_name, num_rows, high_value from user_tab_partitions where table_name = 'ORDERED_INV_T' ;
    These are the results:
    TP_ORDINV_199801 0 TO_DATE(' 1999-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_199901 0 TO_DATE(' 2000-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200001 0 TO_DATE(' 2001-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200101 0 TO_DATE(' 2002-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200201 0 TO_DATE(' 2003-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200301 0 TO_DATE(' 2004-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200401 0 TO_DATE(' 2005-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200501 0 TO_DATE(' 2006-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200601 0 TO_DATE(' 2007-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200701 0 TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200801 0 TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_200901 0 TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_201001 0 TO_DATE(' 2011-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_201101 0 TO_DATE(' 2012-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_201201 0 TO_DATE(' 2013-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')
    TP_ORDINV_MAX 24976 MAXVALUE
    Pay attention to the last record

    >
    used the Exchange Partition feature to swap segments between 2 tables- one Partitioned, and one Non-Partitioned. The exchange went well. However, all the data in the partitioned table has gone to the partition which stores the maxbound values.
    >
    That isn't possible. The data in the partition before the exchange could only have gone to the non-partitioned table.
    Please edit you post and add \ tags on the lines before and after your code to preserve formatting. See the FAQ for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Re: exchange partition on weekly partition

    We have divided month in 4 week partitions Week 1 start from date 2 to 8, Week2 start from 9 to 15, Week3 start from 16 to 22 and Week4 start from 23 to 1st of coming month.
    Tables has huge data (some tables size in TB). Can exchange partition will work on it or I have to change it to daily partition (with huge data)?
    Yes - exchange partition will work on it. As I said above:
    EXCHANGE PARTITION just exchanges two 'like' partitions so doesn't care what time period the partitions represent (daily, weekly, monthly, etc).
    That allows you to EXCHANGE one 'weekly' partition with a temp table.
    But you said you are loading data daily:
    We are loading data in our dataware house on daily basis from temp to stage and fact tables through insert command
    So you don't have a weeks worth of data to exchange; you have a 'days' worth of data. That can only be EXCHANGED with a partition that is intended to hold a days worth of data.
    If you are manually adding partitions to your current table then just begin manually add DAILY partitions instead of adding weekly ones. Then you can do a simple daily EXCHANGE to load the data.
    Or you could REDEFINE your existing table to use daily partitions by just defining partitions that correspond to your existing weekly ones to hold your current data and then daily partitions for your new data.
    CREATE TABLE SCOTT.PARTITION_DAILY_TEST
      ID       NUMBER(10),
      MY_DATE  DATE
    PARTITION BY RANGE (MY_DATE)
    INTERVAL( NUMTODSINTERVAL(1,'DAY'))
      PARTITION P_201204_WEEK1 VALUES LESS THAN (TO_DATE(' 2012-04-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
      PARTITION P_201204_WEEK2 VALUES LESS THAN (TO_DATE(' 2012-04-16 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
      PARTITION P_201204_WEEK3 VALUES LESS THAN (TO_DATE(' 2012-04-23 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
      PARTITION P_201204_WEEK4 VALUES LESS THAN (TO_DATE(' 2012-05-02 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
      PARTITION P_201205_WEEK1 VALUES LESS THAN (TO_DATE(' 2012-05-08 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    That table definition above defines specific partitions for existing data but tells Oracle to CREATE and USE daily partitions for new data.
    Then you can use EXCHANGE PARTITION (via a work tablel) to move data from your current table partitions to the new table partitions.

    If you are manually adding partitions to your current table then just begin manually add DAILY partitions instead of adding weekly ones. Then you can do a simple daily EXCHANGE to load the data.
    Or you could REDEFINE your existing table to use daily partitions by just defining partitions that correspond to your existing weekly ones to hold your current data and then daily partitions for your new data.
    rp0428,
    Just for confirmation can we add daily partition instead of weekly in our existing table for future data and current data will remain in weekly partition.

  • Exchange Partition Problem

    Hi,
    I am trying to create a partition table for a non parttition table.
    create table dept_test partition by list(deptno)
    (partition p10 values(10),
    partition p20 values(20),
    partition p30 values(30),
    partition p40 values(40))
    as select * from dept where 1=0;
    create table dept1
    as
    select * from dept;
    alter table DEPT_TEST
    exchange partition p10
    with table dept1
    WITHOUT VALIDATION;
    BEGIN
    EXEC dbms_stats.gather_table_stats('usr','DEPT_TEST','P10',33);
    EXEC dbms_stats.gather_table_stats('usr','DEPT_TEST','P20',33);
    EXEC dbms_stats.gather_table_stats('usr','DEPT_TEST','P30',33);
    EXEC dbms_stats.gather_table_stats('usr','DEPT_TEST','P40',33);
    END;
    select * from dba_tab_partitions where table_name='DEPT_TEST';
    SELECT * FROM DEPT_TEST WHERE DEPTNO=10;
    SELECT * FROM DEPT_TEST WHERE DEPTNO=20;
    In the dba_tab_partitions,row count for p10 is showing as 4. when i ran the query for the value 10 ,i got 4 row but for 20 no rows.
    Can you please tell me what is the problem?
    Thanks.

    Partition exchange moved all the data to partition p10. Partitions p20, p30 and p40 are empty. Evaluating condition WHERE DEPTNO = 10 optimizer relys on the partition definition VALUES(10). It's enough to do partition pruning only to satisfy the condition. The same partition pruning takes place for the condition DEPTNO = 20, but partition p20 is empty and the query returns no rows.
    SQL> set autotrace on explain
    SQL> SELECT * FROM DEPT_TEST WHERE DEPTNO=10;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    Execution Plan
    Plan hash value: 2891473902
    | Id  | Operation             | Name      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT      |           |     1 |    20 |     3   (0)| 00:00:01 |       |       |
    |   1 |  PARTITION LIST SINGLE|           |     1 |    20 |     3   (0)| 00:00:01 |     1 | 1 |
    |   2 |   TABLE ACCESS FULL   | DEPT_TEST |     1 |    20 |     3   (0)| 00:00:01 |     1 | 1 |
    SQL> SELECT * FROM DEPT_TEST WHERE DEPTNO=20;
    no rows selected
    Execution Plan
    Plan hash value: 2891473902
    | Id  | Operation             | Name      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT      |           |     1 |    30 |     2   (0)| 00:00:01 |       |       |
    |   1 |  PARTITION LIST SINGLE|           |     1 |    30 |     2   (0)| 00:00:01 |     2 | 2 |
    |   2 |   TABLE ACCESS FULL   | DEPT_TEST |     1 |    30 |     2   (0)| 00:00:01 |     2 | 2 |
    ---------------------------------------------------------------------------------------------------Regards,
    Dima
    Message was edited by:
    dimacit

  • ORA-02266: unique/primary keys - error while using Exchange Partition

    Hi All,
    While using EXCHANGE PARTITION statement as given below,
    ALTER TABLE SOURCE_TABLE EXCHANGE PARTITION PRT_EXCG_PRTN WITH TABLE TARGET_TABLE
    we are getting this error,
    ORA-02266: unique/primary keys in table referenced by enabled foreign keys
    However, there are no tables have foreign keys referring this TARGET_TABLE, we checked this by referring
    USER_CONSTRAINTS table, it has only primary key and NOT NULL constraints.
    SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME like 'TARGET_TABLE';
    We are using the following version,
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    PL/SQL Release 9.2.0.6.0 - Production
    CORE     9.2.0.6.0     Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.6.0 - Production
    NLSRTL Version 9.2.0.6.0 - Production
    Is it due to any error in our end or it could be a bug in Oracle and should we go for any patch updation ?
    Please guide us to resolve this error as soon as possible, thank you.
    Regards,
    Deva

    *** Duplicate Post ***
    Please Ignore.

  • What is the threshold to decide whether partitioning is needed or not?

    I have an oracle 10g enterprise edition but partitioning option is not purchased yet. I foresee the total amount of data by the end of year 2012 would be about 200 to 300 GB and by end of year 2013 will be 400 GB, year 2014 will be 500 GB. There may be four or five tables with about 2 million records (and these will be the biggest tables).
    I have read that partitioning is definitely needed when the size of the database exceeds 500 GB. Are there any other criteria/threshold which suggests at what point in time the partitioning option needs to be recommended?

    Hi,
    whether or not you need partitioning depends not only on your data size, but mostly on your data structure. If you can think of "units" or "chunks" that your data can be broken in, and your business needs are such that they could be satisfied by one or a few "chunks", then partitioning may be the solution for you. For example, if your main application table stores data chronologically, and you often need to wipe off data for one month, or move it to cheaper storage, or take it offline for some kind of maintenance. Or if your data is distributed more or less uniformly across 20 different locations, and your users are often interested in seeing aggregate reports for just one location, etc.
    If your data doesn't have a natural partitioning key, and cannot be broken into convenient "chunks" by this key, then not only partitioning may not improve your performance, it can make it worse.
    There is a common misconception about partitioning: people tend to think of partitions as a way to complement indexing to get better selectivity. E.g. you have a table with columns a (indexed) and b (not indexed), and you have a report using WHERE a=:a and b>:b and think "ok, let me range-partition my table on b, then my report will run even faster with the combined power of indexing and partition pruning". In reality, your report will be running slower, maybe even much slower, depending on how many partitions will be covered by b>:b, because instead of doing an index unique scan once, you'll be doing it once per every index partition in your partition range. Of course, global indexes don't have this problem, but they sort of cancel the advantages of partitioning (what good is being able to operate on a small chunk of data if you have to follow up by rebuilding a huge global index?).
    Another common misconception is urge to partition just because a table is becoming "too big". I've seen people doing partitioning on some obscure syntetic keys only used in table joins explaining that "well I know this is not a good partitioning key but I had to partition this table, it was becoming oh so big". In best case scenario, performance won't improve, but very likely it will get worse.
    Best regards,
    Nikolay

Maybe you are looking for

  • How to search a tree control.

    Hi all, I just started learning Flash Builder not too long ago, quite a learning experience I have to say. I am a little lost and woul like some help from you guys. I am trying to build a menu tree that will display and image and information about th

  • Check Authorization for User ID

    hi all, as per i know, i can check the authentication by check an object as the following   AUTHORITY-CHECK OBJECT 'ZOBJECT'            ID 'ACTVT' FIELD '_____'. in case i have user id (user does not launch the program by himself) and i want to check

  • An exception thrown while lUIX Images with Websphere app server

    Hi All, we are using the UIX controls in our product. Environment Specification : Application server we are using is WebSphere6.1.0.9 UIX Implementation-Version: 2.2.24 when we deploy our application and server is started and user performs some opera

  • Consistent crash when playing .avi f

    I have a .avi file which runs for 42 sec. It worked fine until I put the latest firmware on there. Now it starts .6 seconds into it every time. What's more, if I rewind it to the start, the player bombs completely - black screen, I have to reset. Any

  • ICloud control panel freeze after applying settings

    Just installed iTunes 10.5 and iCloud control panel 1.0 on my Windows 7 64-bit computer. I am signed in with my Apple-ID but when I enable photo Stream and hit the Apply button the control panel freezes. I have restarted the computer wish resulted in