Exforsys
+ Reply to Thread
Results 1 to 3 of 3

Want to change the datatype of the column

This is a discussion on Want to change the datatype of the column within the Oracle Database forums, part of the Database category; Hi I have data in a table. I need to change the datatype of a column. say from int to ...

  1. #1
    siri6589 is offline Junior Member Array
    Join Date
    Jan 2007
    Answers
    5

    Want to change the datatype of the column

    Hi

    I have data in a table. I need to change the datatype of a column.

    say from int to varchar2.

    I am working on oracle9i database.

    I used alter command but that will work only if the table is empty.

    Please can anyone suggest me the solution I would be very much thankful.

    Also if i created a temp column is there any command to copy the data from one column to temp column.


    Your help would be greatly appreciated.

    Thank you very much,
    siri6589


  2. #2
    techguru is offline Senior Member Array
    Join Date
    Mar 2005
    Answers
    112
    Hello Siri,

    Step 1: Create a temp column

    Step 2 : update table set temp column = old column

    Step 3: add new column with desired data type

    step 4: drop the old column

    step 5 : update table set new column = temp column

    Step 6: delete temp column

    Let me know how it goes..

    Thanks,


  3. #3
    jyaseena is offline Junior Member Array
    Join Date
    Aug 2005
    Answers
    8

    Guru is greate

    its a good idea...but I think he is asking a single command ..right?


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...