How to Add a Default Value to a Column in PostgreSQL

-- Example: Orders have a default total of 0 cents
alter table orders alter column total_cents set default 0;

-- Example: Items are available by default
alter table items alter column available set default true;
Cta

Shared queries and folders ✅ Version history ✅ One-click connection to PostgreSQL ✅

Get more done, together, with PopSQL and PostgreSQL