Create table emp
(id number(9), name varchar2(20),salary
number(9,2));
The table has 100 records after table created.Now i nee to
change id's Datatype is to be Varchar2(15). now

Alter table emp modify(id varchar2(15),name varchar2(20),
salary number(9,2));

Whether it will work or returns error? post answer with
explanation.

Answer Posted / abhishekjaiswal

They are asking change datatype from number to varchar2..So it is not possible if table have data..this will give error 'ORA-01439: column to be modified must be empty to change datatype'.You can alter table and modify that column in same data type.
See Example 
select * from a;
   N F
----- -------------------
    5
    1
    3
alter table a modify  (n varchar2(10))
                       *
ERROR at line 1:
ORA-01439: column to be modified must be empty to change datatype

  1* alter table a modify  (n number)
SQL> /

Table altered.<<<<<<<<<<<<<<<<<

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sql table?

686


Is it possible to sort a column using a column alias?

814


Explain foreign key in sql?

785


What is a database event trigger?

797


what is 'trigger' in sql? : Sql dba

723






Is join same as left join?

750


What is trigger in sql?

781


How can we solve sql error: ora-00904: invalid identifier?

882


How can you create an empty table from an existing table?

796


Can we enter data in a table in design view?

708


How can you view the errors encountered in a trigger?

730


Which are the different case manipulation functions in sql?

733


what are the advantages and disadvantages of cascading style sheets? : Sql dba

799


How can you fetch first 5 characters of the string?

706


How to write a single statement that concatenates the words ?hello? And ?world? And assign it in a variable named greeting?

821