Skip to Main Content

SQL & PL/SQL

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!

Adding new column at specific position

PandeeshMay 15 2011 — edited May 15 2011
Hi,

I am creating a new table:

Create table item_test(id Number(8), item_desc varchar2(48))

Now i want to add one more column price as the second column in between id and item_desc columns..

if i execut*e*

alter table item_test add price Number(8)

The price filed will be added at the end.

1)But i understand that in relational databases the order of the columns are not vital..however we can select in the order in which want by using the select statement..

2) Another approach i read is,CTAS(Create Table As Select)

a)Add the column as usual..

b) create table item_test_temp as ( select id,price,item_desc from item_test)

c) Then drop the original table

d)then again create the original table again from the temp table using CTAS.

Is there any other efficient way to achieve this?

Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2011
Added on May 15 2011
15 comments
1,894 views