NOTE: I am not a dba. 🙂
I have a database table that a client needs to set a column's default value. This table has 1.5mil+ records in it and this column is already populated on all existing records (they do this manually right now). They would like this column to be set automatically on all new records that their users create.
Would it cause down time or any major latency issues to set this column's default value during business hours?
Best Answer
In order to apply this change the process will need to acquire a
SCH-M
lock and once it's got that it should be pretty instant (a metadata only change.)The only risk is that if you have a long running transaction that is using the table whilst the
ALTER TABLE
statement waits to acquire the lock any other subsequent requests coming in that require a lock on the table will be queued up behind it to prevent your alter request from being starved.So you could end up blocking production queries for a while until the lock is granted and the change made.