Modify table: How to change 'Allow Nulls' attribute from not null to allow null

后端 未结 8 867
星月不相逢
星月不相逢 2020-12-12 13:48

How to change one attribute in a table using T-SQL to allow nulls (not null --> null)? Alter table maybe?

8条回答
  •  难免孤独
    2020-12-12 14:33

    Yes you can use ALTER TABLE as follows:

    ALTER TABLE [table name] ALTER COLUMN [column name] [data type] NULL
    

    Quoting from the ALTER TABLE documentation:

    NULL can be specified in ALTER COLUMN to force a NOT NULL column to allow null values, except for columns in PRIMARY KEY constraints.

提交回复
热议问题