I want to add a new column that is NULL for existing rows, but has default value for new rows.
This:
ALTER TABLE foo ADD COLUMN bar timestamp NULL DEFAULT clock_timestamp();
Won't work, because it would add default value to existing rows.
This would work:
ALTER TABLE foo ADD COLUMN bar timestamp NULL;
ALTER TABLE foo ALTER bar SET DEFAULT clock_timestamp();
but I need to run 2 queries. Is it possible to do in 1 query?