Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Changing data type of non-empty table

441344Sep 13 2007 — edited Sep 13 2007
Hi,

I want to change the data type of a column in a table from NUMBER to VARCHAR2. The table isn't empty. Is there a way I can change the data type without removing the data from the table because the table is big.

Would appreciate your thoughts on it.

Pasted below is a sample table:

CREATE TABLE test1 (
c1 NUMBER(5),
c2 NUMBER(3)
);


INSERT INTO test1 VALUES (1,2);
INSERT INTO test1 VALUES (1,2);
INSERT INTO test1 VALUES (1,2);
INSERT INTO test1 VALUES (1,2);
INSERT INTO test1 VALUES (1,2);
INSERT INTO test1 VALUES (1,2);
INSERT INTO test1 VALUES (1,2);

COMMIT;


ALTER TABLE test1 MODIFY (c2 VARCHAR2(25));

ERROR at line 1:
ORA-01439: column to be modified must be empty to change datatype

Thanks and Regards,
Muthu
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2007
Added on Sep 13 2007
4 comments
3,843 views