Cost to change hash partition key column in a history table

Hi All,
I have the following scenario.
We have a history table in production which has 16 hash partitions on the basis of key_column.
But the nature of data that we have in history table that has 878 distinct values of the key_column and about 1000 million data and all partitons are in same tablespace.
Now we have a Pro*C module which purges data from this history table in the following way..
> DELETE FROM hsitory_tab
> WHERE p_date < (TO_DATE(sysdate+1, 'YYYYMMDD') - 210)
> AND t_date < (TO_DATE(sysdate+1, 'YYYYMMDD') - 210)
> AND ROWNUM <= 210;
Now (p_date,t_data are one of the two columns in history table) data is deleted using thiese two date column conditions but key_column for partition is different.
So as per aboove statement this history table containd 6 months data.
DBA is asking to change this query and use partiton date wise.Now will it be proper to change the partition key_column (the existing hash partiton key_column >have 810 distinct values) and what things we need to cosider to calculate cost behind this hash partition key_column cahange(if it is appropriate to change >partition )key_column)Hope i explained my problem clearly and waiting for your suggestions .
Thanks in advance.

Hi Sir
Many thanks for the reply.
For first point -
we are in plan to move the database to 10g after a lot of hastle between client.For second point -
If we do partition by date or week we will have 30 or 7 partitions .As suggested by you as we have 16 partitions in the table best approach would be to have >partition by week then we will have 7 partitions and then each query will heat 7 partitions .For third point -
Our main aim to reduce the timings of a job(a Pro*C program) which contains the following delete query to delete data from a history table .So accroding to the >query it is deleting data every day for 7 months and while deleting it it queries this hug etable by date.So in this case hash partition or range partiton or >hash/range partition which will be more suitable.
DELETE FROM hsitory_tab
WHERE p_date < (TO_DATE(sysdate+1, 'YYYYMMDD') - 210)
AND t_date < (TO_DATE(sysdate+1, 'YYYYMMDD') - 210)
AND ROWNUM <= 210;I have read in hash partition is used so that data will be evenly distributed in all partitions (though it depends on nature of data).In my case i want some suggestion from you to take the best approach .

Similar Messages

  • 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.

  • Updating partition key column would cause a partition change

    while i am executing this query in sql i am getting an error message saying
    that
    updating partition key column would cause a partition change
    SQL> update questionbnkmaster set sectionid=23 where qno=19;
    update questionbnkmaster set sectionid=23 where qno=19
    ERROR at line 1:
    ORA-14402: updating partition key column would cause a partition change
    what can do to update the table without changing to the other fields
    tyhanx in advance
    cinux

    try this
    ALTER TABLE questionbnkmaster ENABLE ROW MOVEMENT
    /Cheers, APC

  • How do I change the order of columns in the responses table?

    How do i change the order of columns in the responses table in FormsCentral?  The default setting puts them in reverse order!

    Hi,
    The issue with the default ordering of columns in the response table is something that we hope to address in the next update to FormsCentral. In the meantime, you can reorder the columns by selecting them then click/drag using the gray area above the column name. As shown below, an orange marker will show you where the columns will be placed when you release the mouse button.
    Sorry for the inconvenience.
    Regards,
    Brian

  • How to know primary key column name form a table name in sql query

    Suppose I only know the table name. How to get its primary key column name from the table name?
    Thanks

    Views don't have primary keys though their underlying tables might. You'd need to pick apart the view to determine where it's columns are coming from.
    You can select the text of the view in question from user_views.

  • Knowing the primary key columns of the given table

    Hi,
    How can I get the primary key columns of the given table?
    Regards,
    Sachin R.K.

    You can find the constraint_name from all_constraints/user_constraints for constraint_type = 'P' (which is the primary key constraint).
    And then see which columns are in for the constriant_name
    in all_cons_columns/user_cons_columns view.
    Below is the example
    select acc.column_name from
    all_cons_columns acc, all_constraints ac
    where acc.constraint_name = ac.constraint_name
    and acc.table_name = 'DEPT' AND acc.owner = 'SCOTT'
    and ac.constraint_type = 'P'
    Hope this helps
    Srinivasa Medam

  • Oracle 11gR2: partition key column, need to be modified

    Hi folks,
    Have a situation, need to increase a column width, which is also a partition key and table is pretty huge, can any one assist, what is the best possible way to achieve this task.
    Thanks in advance.

    No need to build multiple temp tables, do multiple swaps, and do multiple redefines of the temp table columns when you can just build the one table that you need.OK. Could you show us a script for your approach.
    Meantime I show mine.
    Preparation
    create table PART_TEST (part_key number(1), val varchar2(100))
    partition by range(part_key)(
      partition P0 values less than (1),
      partition P1 values less than (2),
      partition P2 values less than (3),
      partition P3 values less than (4)
    insert into PART_TEST values (0,'zero');
    insert into PART_TEST values (1,'one');
    insert into PART_TEST values (2,'two');
    insert into PART_TEST values (3,'three');
    commit;The modification
    set timing on
    create table PART_TEST_P0 as select * from PART_TEST where 1=0;
    create table PART_TEST_P1 as select * from PART_TEST where 1=0;
    create table PART_TEST_P2 as select * from PART_TEST where 1=0;
    create table PART_TEST_P3 as select * from PART_TEST where 1=0;
    alter table PART_TEST exchange partition P0 with table PART_TEST_P0;
    alter table PART_TEST exchange partition P1 with table PART_TEST_P1;
    alter table PART_TEST exchange partition P2 with table PART_TEST_P2;
    alter table PART_TEST exchange partition P3 with table PART_TEST_P3;
    alter table PART_TEST_P0 modify part_key number(6);
    alter table PART_TEST_P1 modify part_key number(6);
    alter table PART_TEST_P2 modify part_key number(6);
    alter table PART_TEST_P3 modify part_key number(6);
    drop table PART_TEST;
    create table PART_TEST (part_key number(6), val varchar2(100))
    partition by range(part_key)(
      partition P0 values less than (1),
      partition P1 values less than (2),
      partition P2 values less than (3),
      partition P3 values less than (4)
    alter table PART_TEST exchange partition P0 with table PART_TEST_P0;
    alter table PART_TEST exchange partition P1 with table PART_TEST_P1;
    alter table PART_TEST exchange partition P2 with table PART_TEST_P2;
    alter table PART_TEST exchange partition P3 with table PART_TEST_P3;Whole modification of the column takes a fraction of second because there is no need to physically move data. Only metadata is changed.

  • Partitioning key columns

    Hi,
    I have created range partitioning on T_SEP
    STEP 1: Create temporary table t_SEP_TMP
    CREATE TABLE  "T_SEP"
       (     "SEP_SID" NUMBER(20,0)  ,
         "SEP_CURR_SID" NUMBER(20,0)  ,
         "BUS_CYC_D" DATE ,
            "FUND_BUS_D"  DATE)
          PARTITION BY RANGE (BUS_CYC_D)
    ( PARTITION STG_1 VALUES LESS THAN ( TO_DATE('19/12/08','DD/MM/YYYY'))
       TABLESPACE STG_1, 
      PARTITION STG_3 VALUES LESS THAN ( TO_DATE('22/12/08','DD/MM/YYYY'))
       TABLESPACE STG_2,
      PARTITION STG_4 VALUES LESS THAN (TO_DATE('23/12/08','DD/MM/YYYY'))
       TABLESPACE STG_3,
      PARTITION STG_5 VALUES LESS THAN (TO_DATE('24/12/08','DD/MM/YYYY'))
       TABLESPACE STG_4,
      PARTITION STG_6 VALUES LESS THAN (MAXVALUE)
       TABLESPACE STG_5
    currently, I have partitioning on only "BUS_CY_D" column, now I need to add one more column to the partitioning key. How can we do this?

    Anurag Tibrewal wrote:
    Hi,
    You can achieve this in following ways.
    1) Using DBMS_REDEFINITION
    2) a) Taking export backup of existing table.
    b) Rename existing table, constraints indexes
    c) Create new table with required paritition key
    d) Import the data to new table.
    Regards
    Anurag3) rename existing table, create table as select to create new table, add index constraints etc
    4) create table as select to create new table, drop existing table, rename new table, add index constraints etc
    5) create new table, for each partition of old table (insert data into new table, truncate old table partition) ... etc.
    I would try not to use the export method unless space was really tight. If space was an issue then I'd prefer 5.

  • Regarding :Modifying the partition key column

    Hi,
    I have Create one table.At that time i did range partition on one column(callend).these table has 1000 millions records.Now I want to chage that partiion on another column (callstart) .How can i do this.
    Kindly provide me suggestion
    Regards.

    Much nicer type of reply:
    My best advice would be to just create a new table.
    Since your data is already partitioned, it is unreasonable at that time to try to "change" that partitioning column.
    Yes, you obviously have to, otherwise you wouldn't be asking I'm sure. Go ahead and just create a new partitioned table based on callstart and relax for a few hours :)
    You might want to even use two separate boxes within the same network to perform this task. So that one box is focused on selecting and sending and the other box is worried about partitioning the data to a new table. Access via DB link.

  • How to change (decrease) primary key column length?

    Hi all,
    I have plenty of data in the table and I need to decrease the primary key column from CHAR(17) to CHAR(13).
    I try to use:
    ALTER TABLE xx MODIFY (prmy_key (13));
    but Oracle give:
    ERROR at line 1:
    ORA-01441: column to be modified must be empty to decrease column length
    Can anyone give me advice on what is the best way to decrease column length? Thanks in advance for your help.

    To add to the above, I have done a simple test in the lines that I was suggesting the solution for this problem,
       CREATE TABLE testA
       (pk_col   varchar2(20), jd date, constraint pk1 PRIMARY KEY(pk_col));
       --Insert data into testA
       create table testB as select * from testA;
       TRUNCATE table testA;
       ALTER TABLE testA modify(pk_col VARCHAR2(10));   
       INSERT INTO testA SELECT substr(pk_col, 1, 10), jd from testB;
       DROP TABLE testB;
       Select constraint_name, constraint_type, status from all_constraints
       Where table_name = 'TESTA';
       CONSTRAINT_NAME                C STATUS
       PK1                            P ENABLEDAlter command is successful as the table is empty. TRUNCATE flushes the data and resets the high water mark keeping all the constraints. If we safely want to use the TRUNCATE as far as storage issues are concerned,
    TRUNCATE table table_name reuse storage;
    I think, this would accoplish what has been asked.
    Let me know,
    SriDHAR

  • Key column in an internal table?

    Hi all,
    Can somebody tell me, if it is possible to create an internal table with a key-column?
    I think it is, but I do not know how? So, How can I make it? Does this keys work exactly like DB table keys?
    Thanks,
    MPM

    I'm not sure if it is correct that sorted tables can only have unique keys.
    The table keys are important for access:
    1. Every table with character fields have got a key by (SAP) definition. An unsorted standard table's key consists of all non-numeric fields. In this case the access will be sequential except for a binary search.
    2. Sorted tables may have one unique or non-unique key consisting odf one or more fields. If the key is not unique, the entry with the lowest index is accessed.
    3. Only Hash tables require a unique key
    4. Only one key per internal table is allowed (no secondary keys as in other programming languages or database definitions).
    5. See also:
    http://help.sap.com/saphelp_47x200/helpdata/en/90/8d7325b1af11d194f600a0c929b3c3/frameset.htm
    regards,
    Clemens

  • How to create unique key column in ROLAP fact table?

    Hi all,
    Is there a way to create a single column primary key (or unique index) on my ROLAP cube (and fact tables) in OWB? if so, what I should do in my mappings?
    Thanks!
    - Andrew

    Have you all conformed dimensions between the two facts?

  • Change the Value of column of the internal table at run time

    Hello Experts,
    With the below code i am able to determine the value hold
    by internal table at run time for a sepcific column but i am not getting the way
    of how to update the internal if one of the value is changed,
      lr_desc_table ?= cl_abap_typedescr=>describe_by_data( itab  ).
      lr_desc_struc ?= lr_desc_table->get_table_line_type( ).
    loop at itab assigning <fs_data>.
        loop at lr_desc_struc->components ASSIGNING <fs_comp_wa>.
          assign component  <fs_comp_wa>-name of structure <fs_data> to <fs_field>.
          lv_excel_row = <fs_field>.
         CALL FUNCTION 'SCP_REPLACE_STRANGE_CHARS'
            EXPORTING
              INTEXT  = lv_excel_row
            IMPORTING
              OUTTEXT = lv_excel_row.
          assign lv_excel_row to <fs_field>. "this is not changing the value actually hold in internal table
        endloop.
      endloop.

    Hi,
    Resolved this issue with the code mentioned below.
    Code:
    loop at lt_export_items assigning <fs_data>.
      ls_data = <fs_data>.
        loop at lr_desc_struc->components ASSIGNING <fs_comp_wa>.
          assign component  <fs_comp_wa>-name of structure <fs_data> to <fs_field>.
          lv_excel_row = <fs_field>.
          CALL FUNCTION 'SCP_REPLACE_STRANGE_CHARS'
            EXPORTING
              INTEXT  = lv_excel_row
            IMPORTING
              OUTTEXT = lv_excel_row.
              concatenate 'ls_data-' <fs_comp_wa>-name into  lv_var.
              assign (lv_var) to <fs_var>.
              <fs_var> = lv_excel_row.
        endloop.
        modify lt_export_items from ls_data .
        clear:ls_data.
      endloop.
    Take care,
    Sanju

  • How to find out the primary key column of a database table?

    Hi
    Given the following scenario :
    Given an inputfield, the user can enter a table name. The code behind will base on the table name given and extract out the fieldname of the primary key and concatenate the two field to become a unique string.
    Eg. Order ID and Product ID make out a primary key.
    How do i achieve that? Any code sample?
    Regards,
    Rayden

    Check the below code :
    REPORT zTest no standard page heading.
    data : i_DD03P like DD03P occurs 0 with header line.
    data v_table like DCOBJDEF-NAME.
    parameters : p_table like dd02l-tabname.
    start-of-selection.
    v_table = p_table.
    CALL FUNCTION 'BDL_DDIF_TABL_GET'
      EXPORTING
        NAME                = v_table
       STATE               = 'A'
       LANGU               = 'E'
    IMPORTING
      GOTSTATE            =
      DD02V_WA            =
      DD09L_WA            =
    TABLES
       DD03P_TAB           = i_DD03P
      DD05M_TAB           =
      DD08V_TAB           =
      DD12V_TAB           =
      DD17V_TAB           =
    EXCEPTIONS
       ILLEGAL_INPUT       = 1
       OTHERS              = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at i_DD03P.
    if i_dd03p-KEYFLAG = 'X'.
    write:/ 'Key fields', i_dd03p-FIELDNAME.
    endif.
    endloop.
    Thanks
    Seshu

  • 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.

Maybe you are looking for