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

Thread: Convert Datatype

  1. #1
    Join Date
    Mar 2002
    Posts
    17

    Convert Datatype

    Hi, I need help from u.

    I want to convert a data type of one column in a Table. Currently that column is “NUMBER (6)” to be converted as “VARCHAR2 (6)”. Which is the best way u suggests doing it.

    Details abt Table
    Total No of Records: 50,000
    Total No of Columns: 25
    Only Varchar, Char, Number & Date data types in that table.

    Expecting ur reply

    Safedba

  2. #2
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    If the column is empty then you can directly use ALTER TABLE MODIFY command. Otherwise you will have to create a new table and insrt the data.

    HTH
    Sanjay G.
    Oracle Certified Professional 8i, 9i.

    "The degree of normality in a database is inversely proportional to that of its DBA"

  3. #3
    Join Date
    Mar 2002
    Posts
    17
    Mr.Sanjay ,

    The column is not empty and moreover this is master table linked with two detail tables.
    Actually i am looking, is there any way to covert datatype while doing Export or Import.

  4. #4
    Join Date
    Feb 2000
    Location
    Singapore
    Posts
    1,758
    I don;t think you can do it by export/import.
    The work around could be.

    1. Create a temp table as
    create table as select * from orig_table

    2. Truncate or delete all rows from orig table.

    3. Use alter table modify to change datatype.

    4. Re-insert all rows into orig table.

    5. drop the temp table.

    You may need to disable the RI constraints before deleting. You can enable them again after inserting back the rows.

    HTH
    Sanjay G.
    Oracle Certified Professional 8i, 9i.

    "The degree of normality in a database is inversely proportional to that of its DBA"

  5. #5
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    How about

    - adding new_column with datatype VARCHAR2(6)
    - UPDATE TABLE SEt new_column = TO_CHAR(old_column)
    - droping old_column from your table
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  6. #6
    Join Date
    Mar 2002
    Posts
    17
    Thanks to Sanjay & jmodic.

    jmodic, my database version is 8.0.6.

  7. #7
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Originally posted by safedba
    jmodic, my database version is 8.0.6.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    GENERAL RULE: each and every technical question in this forums should have at least OS and Oracle release specified.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

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