Results 1 to 4 of 4
  1. #1
    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@.

  2. #2
    Join Date
    Sep 2003
    Posts
    156

    Re: ALTER TABLE : Add a new column in between existing two columns

    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

  3. #3
    Join Date
    Jan 2004
    Posts
    3
    Thanks very much for your reply GhostMan!

  4. #4
    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".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •