Drop columns and how to add them back to the same position
848959May 7 2012 — edited May 8 2012Hi,
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.