How to Add a Default Value to a Column in PostgreSQL - PopSQL

PHOTO EMBED

Thu Aug 12 2021 16:47:15 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

-- 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;

links:

https://www.postgresql.org/docs/9.5/ddl-alter.html

https://www.postgresql.org/message-id/4558AA88.3070102@brainscraps.com
content_copyCOPY

https://popsql.com/learn-sql/postgresql/how-to-add-a-default-value-to-a-column-in-postgresql