如何在SQL Server中的现有列中添加not null? [重复]

时间:2022-06-10 10:19:40

This question already has an answer here:

这个问题在这里已有答案:

I've setup a table in SQL Server 2008 Express and forgot to add a not null constraint to my unique recordid column. I tried to add it afterward, with this statement:

我在SQL Server 2008 Express中设置了一个表,忘了在我的唯一recordid列中添加一个非空约束。之后我尝试添加它,声明如下:

alter table movie_archive alter column RecordID Not null;

but it gives me an error message, saying there's a syntax error at "not". What am I doing wrong?

但它给了我一个错误信息,说“不”的语法错误。我究竟做错了什么?

1 个解决方案

#1


13  

specify the datatype of the column

指定列的数据类型

ALTER TABLE [Table] ALTER COLUMN [Column] INTEGER NOT NULL;

alter table movie_archive alter column RecordID INTEGER Not null;

#1


13  

specify the datatype of the column

指定列的数据类型

ALTER TABLE [Table] ALTER COLUMN [Column] INTEGER NOT NULL;

alter table movie_archive alter column RecordID INTEGER Not null;