Table lock
Lock på hela tabellen istället för enstaka rader. PostgreSQL har 8 nivåer (AccessShare, RowShare, RowExclusive, ShareUpdateExclusive, Share, ShareRowExclusive, Exclusive, AccessExclusive). Tagits primärt vid DDL-operations.
AccessShare = SELECT, kompatibel med allt utom AccessExclusive. AccessExclusive = blockerar allt, inklusive SELECT — taken by ALTER TABLE, DROP TABLE, REINDEX. Anti-pattern: ALTER TABLE ADD COLUMN med default-värde på 100M-row-tabell → hela tabellen rewrite + lock i flera minuter → app-downtime. Modern PG (11+): default ej rewrite för nullable + immutable-defaults. Online-DDL-tools: pt-online-schema-change (Percona), gh-ost (GitHub), pgroll (Xata). MySQL InnoDB online DDL handler många operations utan lock.