Skip to Main Content

Oracle Database Discussions

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!

Drop columns and how to add them back to the same position

848959May 7 2012 — edited May 8 2012
Hi,

My requirement is, I want to drop columns in the existing table and later on, when required I want to add those columns at the same position.

1) Create t_emp table

create table t_emp(
empno varchar2(10) primary key,
ename varchar2(100),
desig varchar2(100),
dept varchar2(100),
salary number(10,2));

2) Dropping the below columns,

alter table t_emp
drop (desig, dept);

3) Add those columns again.

alter table t_emp
add (desig varchar2(100),
dept varchar2(100))

4) desc t_emp

Now, the columns order is changed, I would like to bring to the original columns position, that is,

empno, ename, desig, dept, salary

I'm trying through few work-around for this, like using a swap table. Please share your knowledge and what would be the apt method.

Thank you.
This post has been answered by sb92075 on May 7 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 5 2012
Added on May 7 2012
3 comments
475 views