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!

How can I change the datatype from varchar to number which is already has default Char value

DINESH EDVINMar 17 2016 — edited Apr 11 2016

Hi,

I have a table "Myemp". In this table I have a column stats "Phone_number"  which is the in Varchar(15) format and also it has default value as 'XXX-XXX-XXXX'. So now I wish to change this datatype to Number(15). I removed all the values in this column. when I was trying to change the data type it throws an error stats that "ORA-01722: invalid number". How could I change that datatype. My query and table structure are follows.


Alter table Myemp modify phone_number number(15);

ORA-01722: invalid number
Desc Myemp;
TableColumnData TypeLengthPrecisionScalePrimary KeyNullableDefaultComment
MYEMPEMP_IDNUMBER- 60- nullable- -
FIRST_NAMEVARCHAR225- - - nullable'XXXXXXXXX'-
LAST_NAMEVARCHAR225- - - - 'YYYYYYYYY'-
CAST_IDNUMBER- 100- nullable- -
EMAILVARCHAR230- - - - 'XXX@YYY.COM'-
PHONE_NUMBERVARCHAR215- - - nullable'XXX-XXX-XXXX'-
HIRE_DATEDATE7- - - - - -




Thanks in advance,

Dinesh Kumar.



This post has been answered by Nimish Garg on Mar 17 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2016
Added on Mar 17 2016
14 comments
4,396 views