PostgreSQL 11为表增加带有默认值的列


 

以下是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.


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM