If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > ALTER TABLE : Add a new column in between existing two columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Jan 2004
Posts: 3
ALTER TABLE : Add a new column in between existing two columns

Hi,

I have a table XYZ. It has the fields A, B, C and D. XYZ has lots of data. I need to add a column (B1) in between the columns B and C. So that the column order would become A, B, B1, C and D. Is there any direct query to add a column in between existing two columns? Bcos I cannot drop any column or recreate the same table.

Kindly help me if you have any idea.

Thanks in Advance,
Selv@.
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Sep 2003
Posts: 156
Re: ALTER TABLE : Add a new column in between existing two columns

Quote:
Originally posted by markselva
Hi,

I have a table XYZ. It has the fields A, B, C and D. XYZ has lots of data. I need to add a column (B1) in between the columns B and C. So that the column order would become A, B, B1, C and D. Is there any direct query to add a column in between existing two columns? Bcos I cannot drop any column or recreate the same table.

Kindly help me if you have any idea.

Thanks in Advance,
Selv@.
Columns (or rows for that matter) do not have a sequence in a relational database. Well, that's what relational theory says anyway.

It is therefore dangerous to rely on the order of columns...always use columns lists in selects/inserts etc.

just alter the table and add the new column. select statements can determine the column sequence you want returned.
__________________
rgs,

Ghostman
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks very much for your reply GhostMan!
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Location: down on the cube farm, left then right then another left
Posts: 467
As was reported ordering is not important nor should it be relied upon. If you are concerned about aesthetics or like your columns grouped together visually I believe you could export the data, recreate your table with the columns ordered/grouped however you wish and then re-import the data.
__________________
NOTE: Please disregard the label "Senior Member".
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On