How to add a column to an existing table in MySQL?
ALTER TABLE students ADD COLUMN email VARCHAR(100);
ALTER TABLE students ADD COLUMN status VARCHAR(10) DEFAULT 'active' AFTER name;
Existing rows get NULL (or the default value) in the new column. To remove it use ALTER TABLE students DROP COLUMN email;. See MySQL ALTER TABLE.
Learn more about the similar topics:
| Tutorials |
|---|
| MySQL Data Types |
| MySQL CREATE DATABASE |
| MySQL USE and SHOW DATABASES |
| MySQL DROP DATABASE |
| MySQL CREATE TABLE |
| MySQL Constraints |
| MySQL DROP TABLE |
| Exercises & Assignments |
|---|
| Write a query to get all column names of a database table |
| Write a query to create a new table with the data and structure of another table |