DBAsupport.com Forums - Powered by vBulletin
Results 1 to 8 of 8

Thread: add new column takes forefer

  1. #1
    Join Date
    Nov 2000
    Posts
    57

    add new column hangs!!

    Here is problem. I am in process of adding new field to table

    ALTER TABLE CUSTOMER ADD
    (
    CUST_FLAG NUMBER)
    /
    Normally to add new field to this table takes couple of seconds . In this case command never finishes. I had to kill session for couple times since it locks table and other application and users can not do updates this table.

    How long whould I wait. NO erros found in log file.
    Does number of existing fields matter? This table have alredy 170 fields.
    Please Help.
    Last edited by Eberman; 10-06-2004 at 02:21 PM.

  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092

    Re: add new column hangs!!

    Originally posted by Eberman
    Here is problem. I am in process of adding new field to table

    ALTER TABLE CUSTOMER ADD
    (
    CUST_FLAG NUMBER)
    /
    Normally to add new field to this table takes couple of seconds . In this case command never finishes. I had to kill session for couple times since it locks table and other application and users can not do updates this table.

    How long whould I wait. NO erros found in log file.

    What's it waiting on? Run a level 8 or 12 10046 trace on the session and look at the trace file.


    Does number of existing fields matter?

    probably not.
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  3. #3
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    Use DBMS_REDEFINITION pkg if you want to add a column online.

    Tamil

  4. #4
    Join Date
    Nov 2000
    Posts
    57
    Could you let me know how to do it?

    Thanks

  5. #5
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    The next demo adds a col SAL in the table T1.

    PHP Code:
    SQLshow user
    USER is 
    "SYS"
    SQLgrant execute on dbms_redefinition to tamil ;

    Grant succeeded.

    SQLgrant dba to tamil ;

    Grant succeeded.

    SQLconn tamil/xxxxxxxx
    Connected
    .


    SQLcreate table t1 (id number primary keyname varchar2(30));

    Table created.

    --- 
    create an interium table that reflect final
    --- 
    SQLcreate table int_t1 (id number primary keyname varchar2(30), sal number);

    Table created.

    SQLexec dbms_redefinition.can_redef_table('tamil','t1');

    PL/SQL procedure successfully completed.


    SQL>  execute SYS.DBMS_REDEFINITION.START_REDEF_TABLE('tamil','t1','int_t1');

    PL/SQL procedure successfully completed.

    SQLinsert into t1 values (10,'Tamil');

    1 row created.

    SQLc/10/20
      1
    insert into t1 values (20,'Tamil')
    SQL> /

    1 row created.

    SQLcommit;

    Commit complete.


    SQLexecute DBMS_REDEFINITION.SYNC_INTERIM_TABLE('tamil','t1','int_t1');

    PL/SQL procedure successfully completed.

    SQLexecute DBMS_REDEFINITION.FINISH_REDEF_TABLE('tamil','t1','int_t1');

    PL/SQL procedure successfully completed.

    SQLdesc t1
     Name                                      Null
    ?    Type
     
    ----------------------------------------- -------- ----------------------------
     
    ID                                        NOT NULL NUMBER
     NAME                                               VARCHAR2
    (30)
     
    SAL                                                NUMBER

    SQL
    select from t1;

            
    ID NAME                                  SAL
    ---------- ------------------------------ ----------
            
    10 Tamil
            20 Tamil

    SQL
    drop table int_t1 ;

    Table dropped
    Tamil
    Last edited by tamilselvan; 10-06-2004 at 06:37 PM.

  6. #6
    Join Date
    Aug 2002
    Location
    Atlanta
    Posts
    1,187
    Could there be a lock on the table as you are trying to add the column? Check dba_blockers and dba_ddl_locks
    I'm stmontgo and I approve of this message

  7. #7
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    and how is it different than adding a column, seems like a lot more commands than a simple one liner - what does this give you?

  8. #8
    Join Date
    Nov 2000
    Posts
    57
    I bounced the instance and all came back to normal.

    Thanks everyone for help.

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