Can I logically reorder columns in a table?

后端 未结 8 1565
抹茶落季
抹茶落季 2020-12-15 02:04

If I\'m adding a column to a table in Microsoft SQL Server, can I control where the column is displayed logically in queries?

I don\'t want to mess with the physical

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 03:01

    You can not do this programatically (in a safe way that is) without creating a new table.

    What Enterprise Manager does when you commit a reordering is to create a new table, move the data and then delete the old table and rename the new table to the existing name.

    If you want your columns in a particular order/grouping without altering their physical order, you can create a view which can be whatever you desire.

提交回复
热议问题