开发者

How can i make not allow column to allow null and Allow Null column to not allow null

开发者 https://www.devze.com 2023-04-09 19:45 出处:网络
Could any one help me to perform below task. How can i make not allow column to allow null and Allow Null column t开发者_Go百科o not allow null.Use ALTER TABLE table_name ALTER COLUMN column_name dat

Could any one help me to perform below task.

How can i make not allow column to allow null and Allow Null column t开发者_Go百科o not allow null.


Use ALTER TABLE table_name ALTER COLUMN column_name datatype [NOT] NULL

Example:

CREATE TABLE #Foo
(
X INT NULL,
Y INT NOT NULL
)

/*This is metadata only change and very quick*/
ALTER TABLE #Foo ALTER COLUMN Y INT  NULL

/*This requires all rows to be scanned to validate the data*/
ALTER TABLE #Foo ALTER COLUMN X INT NOT NULL
0

精彩评论

暂无评论...
验证码 换一张
取 消