PostgreSQL 11为表增加带有默认值的列
2021-06-23 17:38 abce 阅读(687) 评论(0) 收藏 举报
以下是10版本中的说明

即在11版本之前:
ALTER TABLE x ADD COLUMN z text;
it was virtually instantaneous. Get a lock on table, add information about new column to system catalogs, and it's done.
But when you tried:
ALTER TABLE x ADD COLUMN z text DEFAULT 'some value';
then it took long time. How long it did depend on size of table.
This was because postgresql was actually rewriting the whole table, adding the column to each row, and filling it with default value.

浙公网安备 33010602011771号