I want to add a boolean column to a table and have the default value be false for newly created rows, but all existing rows should be set to true. How can I do that?
Advertisement
Answer
First alter table and add column as
alter table table_name add column column_name boolean default false;
Then update value of that column as
update table_name set column_name=true;