- Explore
- Collaborate
- Visualize
- Connect
- Pricing
How to Add a Column in MySQL
Adding a column in MySQL involves using the ALTER TABLE
command.
Here's an example of adding a created_at
datetime column to your users
table:
ALTER TABLE users ADD created_at DATETIME;
Adding a string (varchar) column with a not null constraint:
ALTER TABLE users ADD bio VARCHAR(100) NOT NULL;
Adding a boolean column with a default value:
ALTER TABLE users ADD active BOOLEAN DEFAULT TRUE;
MySQL offers extensive documentation on supported datatypes in their documentation.
From MySQL query to chart to Slack in seconds
Get to answers faster, together, with PopSQL and MySQL
Previous
From MySQL query to chart to Slack in seconds
Get to answers faster, together, with PopSQL and MySQL