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