How do you add a column or change a table?

SQL changing data safely · Freshers and experienced

Model answer

ALTER TABLE users ADD COLUMN phone VARCHAR(20); Changing types or adding NOT NULL on a large table may lock it or rewrite data, so on live systems add nullable columns first, backfill in batches, then add constraints.

Learn this topic

INSERT, UPDATE and DELETE: Change Data Safely in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions