Databases · Junior · Question 70 of 75
How do you add a column to an existing table?
- ✓Correct answer:
ALTER TABLE users ADD COLUMN phone text; - 2
INSERT COLUMN phone INTO users; - 3
UPDATE users ADD phone text;
Explanation
In PostgreSQL adding a nullable column (or one with a constant default) is instant even on big tables. Changes like this belong in a migration.