Does adding a null column to a postgres table cause a lock?
问题 I think I read somewhere that running an ALTER TABLE foo ADD COLUMN baz text on a postgres database will not cause a read or write lock. Setting a default value causes locking, but allowing a null default prevents a lock. I can't find this in the documentation, though. Can anyone point to a place that says, definitively, if this is true or not? 回答1: The different sorts of locks and when they're used are mentioned in the doc in Table-level Locks. For instance, Postgres 11's ALTER TABLE may