Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: Suggestions solicited - Change Column Datatype from Number to
Could you preserve the constraints and indices if you do somthing similar like
create table temp as select * from table1 nologging TRUNCATE table table1
ALTER TABLE table1 NOLOGGING;
ALTER TABLE table1 MODIFY(column...);
Do a direct load insert
ALTER TABLE table1 LOGGING;
DROP TABLE temp
I have not done direct load insert but read it can be done for NOLOGGING Rick
DENNIS WILLIAMS <DWILLIAMS_at_LIFE To: Multiple recipients of list ORACLE-L TOUCH.COM> <ORACLE-L_at_fatcity.com> Sent by: cc: root_at_fatcity.co Subject: RE: Suggestions solicited - Change Column m Datatype from Number to 10/24/2002 04:35 PM Please respond to ORACLE-L
Deepak, If there are many columns on these tables, your method may be best. However, this will generate a lot of redo. You can usually accomplish this with a CTAS nologging, which won't generate redo. If you really don't want to change the location, you can:
create table temp as select * from table1 nologging
drop table table1
create table table1 (column, column . . . ) as select * from temp
nologging
drop table temp
Dennis Williams
DBA, 40%OCP
Lifetouch, Inc.
dwilliams_at_lifetouch.com
-----Original Message-----
Sent: Thursday, October 24, 2002 3:15 PM
To: Multiple recipients of list ORACLE-L
We have a need to change the datatype of several columns in a table from number to varchar2. Most of the rows have data in these columns hence a direct 'alter table ...' will not work.
We plan to create a temp table, move the data from these colums to that table, modify the column datatype from number to varchar2 and then update the colums with the data that was moved to the temp table.
Any suggestions/comments or a better way to do this ? Oh, and we are on 8.1.7.1
thanx
deepak
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: DENNIS WILLIAMS INET: DWILLIAMS_at_LIFETOUCH.COM Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- 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-LReceived on Thu Oct 24 2002 - 16:18:08 CDT
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: Rick_Cale_at_teamhealth.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- 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).
![]() |
![]() |