Is it possible to insert a new column between two existing columns?for ex:i have a table with two cols:rollno and dateofbirth.suppose if i want a new column named 'name' to be included in between rollno and dateofbirth. is it possible.I know it is possible thro enterprise mgr. how to do using T-SQL

Showing Answers 1 - 18 of 18 Answers

rabbi

  • Jul 3rd, 2006
 

It is impossible to do this
.It is also impossible to do this through enterprise manager
Enterprise manager's jobYou can do it during table creation. but you cannot do it to an existing table.

  Was this answer useful?  Yes

MADHU

  • Sep 1st, 2006
 

How does one add a column to the middle of a table?
SQL>create table test (ename varchar2(20),salary number);
Table created

SQL>desc test;
Name Null? Type
---------------------- ----------- ---------------
ENAME VARCHAR2(20) SALARY NUMBER

[i]SQL>rename test to test1;
Table renamed
[ii]SQL>create table test2 (id varchar2(20));
Table created
[iii]SQL>create table test as(select test1.ename,test2.id,test1.salary from test1,test2);
Table created
........................................................................................
SQL>desc test;
Name Null? Type
----------------------------------------- -------- --------------
ENAME VARCHAR2(20)
ID VARCHAR2(20)
SALARY NUMBER

  Was this answer useful?  Yes

prakash

  • Nov 15th, 2006
 

Hi,

        It is not possible to add a column in between the existing cols. And as far as the oracle consern, you need not to worry about the sequence of the cols in a table. it will not affect your queryies at all.

        If still you want to get this done just for visual purpose, then you can rename your existing table, add one more field to it and create a view with whatever column order you want...

  Was this answer useful?  Yes

Sushant

  • Jan 3rd, 2013
 

Oracle doesnt allow inserting column in between two. But there are work around to do this. Simple and best one is to add the new column at the end of table. Then rename that table, renaming table will ensure that all constraints and indexes will remain intact. Then create the view with the same name on this renamed table with what ever order you want.

  Was this answer useful?  Yes

Ehsan Rehmani

  • Apr 23rd, 2013
 

No, you cant insert column between existing columns in oracle database but, you can add or insert column in a table at end of last column.

  Was this answer useful?  Yes

prerrak_pandya

  • Mar 6th, 2020
 

thank_you, its really worked!
its make my day,
something awesome new to learn

  Was this answer useful?  Yes

sanjay mehra

  • Apr 3rd, 2020
 

Not possible

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions