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 a temporal table?

488


Is it possible to read/write files to-and-from PL/SQL?

648


How many types of keys are there in sql?

548


What is audit logout in sql profiler?

585


what is a stored procedure? : Sql dba

543






What are the ways on commenting in a pl/sql code?

509


what is the difference between delete and truncate statement in sql? : Sql dba

539


Can we call procedure in select statement?

512


What are expressions?

559


What are % type and % rowtype?

565


What problem one might face while writing log information to a data-base table in pl/sql?

548


What are different types of triggers?

548


what are the different type of normalization? : Sql dba

548


Write a query to find the names of users that begin with "um" in sql?

492


Does sql*plus have a pl/sql engine?

559