在 SQL Server 2005 中的现有列之后添加新列的 SQL 查询

问题描述:

我需要一个 SQL 查询,它在现有列之后添加一个新列,因此该列将按特定顺序添加.

I need a SQL query which add a new column after an existing column, so the column will be added in a specific order.

请建议我是否有任何 ALTER 查询可以做到这一点.

Please suggest me if any ALTER query which do that.

Microsoft SQL (AFAIK) 不允许您更改表并在特定列之后添加列.最好的办法是使用 Sql Server Management Studio,或者尝试删除和重新添加表,或者创建一个新表并手动移动数据.两者都不是很优雅.

Microsoft SQL (AFAIK) does not allow you to alter the table and add a column after a specific column. Your best bet is using Sql Server Management Studio, or play around with either dropping and re-adding the table, or creating a new table and moving the data over manually. neither are very graceful.

MySQL但是:

ALTER TABLE mytable
ADD COLUMN  new_column <type>
AFTER       existing_column