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
why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba
how to analyze tables with 'mysqlcheck'? : Sql dba
what are the different type of sql's statements ? : Sql dba
What is the usage of the distinct keyword?
What are primary key and foreign key and how they work?
what are the limitations of mysql in comparison of oracle? Mysql vs. Oracle. : Sql dba
How do I find sql profiler?
What is information schema in sql?
Explain exception handling in pl/sql?
What is string data type in sql?
How can we solve sql error: ora-00904: invalid identifier?
Can you upgrade sql express to full sql?
How to connect a sql*plus session to an oracle server?
Which sql most popular?
how to rename an existing column in a table? : Sql dba