DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Update

  1. #1
    Join Date
    Oct 2007
    Posts
    37

    Update

    I am applying updates to a table based on partition key. I need to apply 50,000 updates. I need help with the most efficient way to apply the 50,000 updates to the partitioned table. The column to update has a constant value and two other columns values changes.

    Lucky

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    50K updates is not such a big deal.
    Do you know how many updates do you have to apply in each partition?... Depending on conditions you may want to set a transaction per partition.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Oct 2007
    Posts
    37

    Updates

    "Depending on conditions you may want to set a transaction per partition."

    Please elaborate a little bit more on your above statement. I am updating one partition key among several. The update information to be applied is in a text format.

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by Lucky A
    "Depending on conditions you may want to set a transaction per partition."

    Please elaborate a little bit more on your above statement. I am updating one partition key among several. The update information to be applied is in a text format.
    If your process is bound to hit just one partition then your process does not meet the conditions

    Are you planning to tell us how many rows do you have in your table?
    ... in your affected partition?
    ... where you are extending the size of the affected columns?
    ... how dense are your data blocks?
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  5. #5
    Join Date
    Jan 2001
    Posts
    2,828
    Hi

    50K updates are not a big deal if your update statement has the partitioning key in it.

    Without knowing too much and assuming your update statement is simple then i would do the update in a single sql statement.

    Having the partitoning column in the update statement is the key here.

    regards
    Hrishy

  6. #6
    Join Date
    Oct 2007
    Posts
    37

    Updates

    Please give me an example on how I could do the update for 50,000 records.

    Thanks,
    Lucky

  7. #7
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by Lucky A
    Please give me an example on how I could do the update for 50,000 records.
    Are you serious?
    Just look at your business requirements and write your darn update statement.
    Last edited by PAVB; 05-13-2008 at 01:27 PM.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  8. #8
    Join Date
    Oct 2007
    Posts
    37

    Updates

    I do the update query. I am trying to transfer the data from my C:\ drive to the database. I tried creating a an external table and got this error:
    ORA-30657: operation not supported on external organized table.
    This is the update query and data to use. 50,000 of these to apply. Please note that the BUSINESS_UNIT and PROCESS_NAME values are not constant:

    UPDATE LOAD_STAGE_T
    SET DEPT_ID = '021'
    WHERE
    PARTITION_KEY = 300
    AND BUSINESS_UNIT= 077787
    AND PROCESS_NAME = 012345600765432
    AND CLIENT_NUM = 14;
    UPDATE LOAD_STAGE_T
    SET DEPT_ID = '021'
    WHERE
    PARTITION_KEY = 300
    AND BUSINESS_UNIT= 077792
    AND PROCESS_NAME = 012345600850264
    AND CLIENT_NUM = 14;

    How can I get the data from c:\ to the table in the database? Please give suggestion with example please.

    Thanks,
    Lucky

  9. #9
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Is LOAD_STAGE_T your external table?
    --You cannot write on a external table.

    Are you planning to write 50K individual update statements?
    --Please tell me NO!

    What's the table you have to update?
    --Please post desc of your table.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  10. #10
    Join Date
    Oct 2007
    Posts
    37

    Updates

    I was not writing to an External table. I was creating it in order to select from it. The data, in the form of an update query is provided. The data is in the form of UPDATE query in notepad as posted below under heading: "DATA to apply for the update:"; 50,000 updates query which is saved on my C:\ drive. Please note that the BUSINESS_UNIT and PROCESS_NAME values are not constant. Here is the create table posting again:

    This is the create table:

    CREATE TABLE LOAD_STAGE_T
    (
    PARTITION_KEY NUMBER(4) NOT NULL,
    PROCESS_NAME VARCHAR2(20) NOT NULL,
    TENANT_ID VARCHAR2(20),
    DEPT_ID VARCHAR2(3),
    CLIENT_NUM NUMBER(5),
    BUSINESS_UNIT NUMBER(10),
    SERVICE_DATE DATE
    )
    TABLESPACE SKY_BLUE_1
    PCTUSED 40
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    NOLOGGING
    PARTITION BY RANGE (PARTITION_KEY, SERVICE_DATE)
    SUBPARTITION BY HASH (TENANT_ID)

    DATA to apply for the update:

    UPDATE LOAD_STAGE_T
    SET DEPT_ID = '021'
    WHERE
    PARTITION_KEY = 300
    AND BUSINESS_UNIT= 077787
    AND PROCESS_NAME = 012345600765432
    AND CLIENT_NUM = 14;
    UPDATE LOAD_STAGE_T
    SET DEPT_ID = '021'
    WHERE
    PARTITION_KEY = 300
    AND BUSINESS_UNIT= 077792
    AND PROCESS_NAME = 012345600850264
    AND CLIENT_NUM = 14;

    Thanks,
    Lucky

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width