SQL Server 2000 不支持 ALTER TABLE my_table ADD COLUMN column_name VARCHAR(50) AFTER col_name

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15319873/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 14:10:37  来源:igfitidea点击:

ALTER TABLE my_table ADD COLUMN column_name VARCHAR(50) AFTER col_name not supported in SQL Server 2000

sqlsql-serveralter-table

提问by Brainser

I tried the following query in SQL Server 2000 so that I could add a new column after mentioned column.

我在 SQL Server 2000 中尝试了以下查询,以便我可以在提到的列之后添加一个新列。

alter table abc ADD dad varchar(50) after parentname

But it throws me the following error message

但它向我抛出以下错误消息

Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'after'.

消息 170,级别 15,状态 1,第 1
行第 1行:'after' 附近的语法不正确。

Is there any way to do this in SQL Server 2000?

有没有办法在 SQL Server 2000 中做到这一点?

回答by pinaldave

In SQL Server there is no syntax such.

在 SQL Server 中没有这样的语法。

Just use

只需使用

ALTER TABLE abc ADD dad varchar(50)

回答by Greenstone Walker

Short answer: there is no order in a table.

简短回答:表中没有顺序。

A table is a set (an unordered collection) of records, each of which is a set of fields. This is why RDBMS theory prefers the words "record" and "field" rather than "row" and "column".

表是一组记录(无序集合),每个记录都是一组字段。这就是为什么 RDBMS 理论更喜欢用“记录”和“字段”而不是“行”和“列”这两个词。

If you look at a page of data (for example, by using DBCC PAGE in MSSQL) you will see that the storage order of the fields does not correspond to the order you specified in the CREATE TABLE statement.

如果您查看一页数据(例如,通过在 MSSQL 中使用 DBCC PAGE),您将看到字段的存储顺序与您在 CREATE TABLE 语句中指定的顺序不一致。

Ordering is imposed by a SELECT statement.

排序是由 SELECT 语句强加的。

My advice is to stop spending energy and time on the neatness of the CREATE TABLE and spend it on the SELECT statements instead.

我的建议是停止在 CREATE TABLE 的整洁上花费精力和时间,而将其花在 SELECT 语句上。