简体   繁体   English

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

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

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 消息170,第15级,状态1,第1行
Line 1: Incorrect syntax near 'after'. 第1行:'after'附近的语法不正确。

Is there any way to do this in SQL Server 2000? 有没有办法在SQL Server 2000中执行此操作?

In SQL Server there is no syntax such. 在SQL Server中没有这样的语法。

Just use 只是用

ALTER TABLE abc ADD dad varchar(50)

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理论更喜欢单词“record”和“field”而不是“row”和“column”。

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语句上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM