Friday, February 12, 2010

Oracle: You cannot modify the data type of a column if there is data in the column, True or false?

There are hundred records in the student table.


You need to modify the Phone column to hold only numeric value which is currently hlding varchar2. Can we modify it?Oracle: You cannot modify the data type of a column if there is data in the column, True or false?
True.





SQL%26gt; alter table t1 modify phone number(38);


alter table t1 modify phone number(38)


*


ERROR at line 1:


ORA-01439: column to be modified must be empty to change datatype





The easiest way around this is to export your data, truncate the table and import it back to the redefined table. That assumes the existing data is already only numbers i.e. 6005551212 not (600)555-1212. If that is not the case then you need to do some data cleanup first or the import of the data will fail.Oracle: You cannot modify the data type of a column if there is data in the column, True or false?
False, you can 'open' the database in MS access, change any or all values, columns, etc., then export back to oracle/ excell/ whatever.

No comments:

Post a Comment