How do you add a NOT NULL Column to a large table in SQL Server?

前端 未结 12 1885
情话喂你
情话喂你 2020-12-02 15:42

To add a NOT NULL Column to a table with many records, a DEFAULT constraint needs to be applied. This constraint causes the entire ALTER TABLE command to take a long time to

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 15:46

    I think this depends on the SQL flavor you are using, but what if you took option 2, but at the very end alter table table to not null with the default value?

    Would it be fast, since it sees all the values are not null?

提交回复
热议问题