Hi ,
We are on 11.2.0.2 on Solaris 10. I have a need to convert a column which is a number data type to a VARCHAR2 data type. The table has data and the column is part of the primary key. Is it possible? How best can one go about it?
SQL> create table test1
(object_name varchar2(30) NOT NULL, object_id number NOT NULL);
Table created.
SQL>ALTER TABLE TEST1 add(constraint test1_pk primary key (OBJECT_NAME,OBJECT_ID));
Table altered.
SQL> INSERT INTO TEST1 VALUES('EMP',1);
1 row created.
SQL> ED
Wrote file afiedt.buf
1* INSERT INTO TEST1 VALUES('DEPT',2)
SQL> /
1 row created.
SQL> COMMIT;
Commit complete.
SQL> ALTER TABLE TEST1 MODIFY (OBJECT_ID VARCHAR2(20));
ALTER TABLE TEST1 MODIFY (OBJECT_ID VARCHAR2(20))
*
ERROR at line 1:
ORA-01439: column to be modified must be empty to change datatype