The MySQL ALTER command is used to modify the structure of an existing table. It allows you to make various changes, such as adding, deleting, or modify columns within the table. Additionally, the ALTER command is also used to add and drop different constraints associated with an existing table.
How would you add a nullable email VARCHAR(255) column to an existing users table that already has 10k rows?
What happens if you try to change a VARCHAR(50) column to VARCHAR(30) when some existing rows have 40-character values?
You need to add an index on created_at for a reporting query. What's the exact command, and does it lock the table?
We're adding a preferences JSON column to a 50M-row accounts table for a new feature. Walk me through how you'd deploy this without downtime.
A migration to change a primary key from INT to BIGINT failed halfway through on a replica. How do you diagnose and recover?
You need to drop a legacy_status column that's referenced by a foreign key from an audit table. What steps do you take, and in what order?
Design a zero-downtime schema migration strategy for a 24/7 service with 100M+ row tables. Include tooling, validation, and rollback.
How do you coordinate schema changes across a sharded MySQL fleet where each shard has different data volumes?
Compare pt-online-schema-change, gh-ost, and native online DDL for a 500GB table. When would you pick each?
We're splitting a monolith into microservices that share a MySQL cluster. How do you define schema ownership, migration approval, and breakage accountability across 10+ teams?
Design a schema versioning and rollback strategy for a multi-region active-active MySQL deployment with asynchronous replication.
How do you enforce schema change policies (code review, staging validation, canary deployment) across 50+ engineering teams without becoming a bottleneck?