Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: {9i New Features: Online Reorg or DBMS_REDEFINITION Package}

Re: {9i New Features: Online Reorg or DBMS_REDEFINITION Package}

From: Yechiel Adar <adaryechiel_at_hotmail.com>
Date: Sun, 19 May 2002 13:28:18 -0800
Message-ID: <F001.0046434B.20020519132818@fatcity.com>


Got Oracle Update from Xephon today (May 2002). The lead article is about online redefinition by Sameer Wadhwa from NuGenesis Technologies.

His article agrees with you.

Yechiel Adar
Mehish

  Welcome to the next installment of 9i New Features, today's topic is Online changes of objects, specifically we'll cover the new package called DBMS_REDEFINITION.

  The spec for this package is located where all of the other package sources are:

  ORACLE_HOME/rdbms/admin. The file is dbmshord.sql

  So what does this package give us? Well it gives the capability to do online reorganization of a table. Ok so now if you're not confused, you should be :)

  In easy to understand terms, in the past when you wanted to move a table to a new tablespace, drop a column, add a column, change a column datatype, it require a exclusive lock on the table during the operation(which if it was a large table could lock it up for a long time). Well that is no longer the case, those kinds of changes can be done while DML is still being applied to the object.

  Let's take for an example something that all of us have been asking for YEARS, the rename of a column.

  Look at this code, I've included comments within it so its pretty much self-explanatory and you can run it against your 9i database to see what if it really works.

  set serveroutput on size 100000;

  create table sales
  (sales_id number not null,
   sales_amount number(10,2) not null,
   salesman_id number(5) not null,
   tax_amount number(5,2) not null,
   bad_column_name varchar2(20) not null);

  alter table sales add primary key(sales_id)—

  commit;

  execute dbms_redefinition.can_redef_table(USER,'SALES');

  create table sales_temp
  (sales_id number not null,
   sales_amount number(10,2) not null,
   salesman_id number(5) not null,
   tax_amount number(5,2) not null,
   good_column_name varchar2(20) not null);

  alter table sales_temp add primary key(sales_id);

  prompt this is the sales desc before the change   desc sales;

  execute dbms_redefinition.start_redef_table(USER,'SALES','SALES_TEMP', -   'sales_id sales_id, sales_amount sales_amount, salesman_id salesman_id, -   tax_amount tax_amount, bad_column_name good_column_name');

  execute dbms_redefinition.finish_redef_table(USER,'SALES','SALES_TEMP');

  prompt this is the definition of sales AFTER the change   desc sales;
  select * from sales;

  So what you think, pretty kewl(geek kids spelling)?????

  Check out the docs on dbms_redefinition for limitations, etc, don't want to give you all   the answers.

  Until next time all hate mail to /dev/null , all good stuff to 9i_at_oracle-dba.com

  Joe

  PS: I did receive a request for PGA* init.ora parm, its on the list to do.    

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Yechiel Adar
  INET: adaryechiel_at_hotmail.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Sun May 19 2002 - 16:28:18 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US