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!

can we change datatype without deleting records ?

JhilJan 28 2014 — edited Jan 29 2014

Hi all ;


Without deleting records in a table  , can we  change datatype in oracle 10g and 11g ?


SQL> desc emp

Name                                      Null?    Type

----------------------------------------- -------- ----------------------------

NO                                                 NUMBER

NAME                                            VARCHAR2(10)

CITY                                               VARCHAR2(15)

DEP_ID                                          NUMBER

SQL> select * from emp;

        NO NAME       CITY                DEP_ID

---------- ---------- --------------- ----------

        1   madhir   calcutta                10

SQL> alter table emp modify(dep_id  varchar2(5));

alter table emp modify(dep_id varchar2(5))

                       *

ERROR at line 1:

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

SQL>  select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

PL/SQL Release 11.2.0.1.0 - Production

CORE    11.2.0.1.0      Production

TNS for Linux: Version 11.2.0.1.0 - Production

NLSRTL Version 11.2.0.1.0 - Production

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 26 2014
Added on Jan 28 2014
4 comments
11,496 views