Does Adding a Column Lock a Table in SQL Server 2008? -
i want run following on table of 12 million records.
alter table t1 add c1 int null; alter table t2 add c2 bit not null default(0);
i've done in staging , timing seemed fine, before in production, wanted know how locking works on table during new column creation (especially when default value specified). so, know? whole table locked, or rows locked 1 one during default value insertion? or different altogether happen?
yes, lock table.
a table, whole, has single schema (set of columns, associated types). so, at minimum, schema lock required update definition of table.
try think how things work contrariwise - if each row updated individually, how parallel queries work (especially if involved new columns)?
and default values useful during insert
, ddl statements - if specify new default 10,000,000 rows, default value has applied of rows.
Comments
Post a Comment