I recently needed to add multiple columns to an existing table to store summary data calculations and wondered if I could do it in one MySQL ALTER TABLE statement. Turns out you can. And, it’s super simple. Convenient too. Continue reading and learn what I learned…

The Newsletter for PHP and MySQL Developers
Receive a copy of my ebook, “10 MySQL Tips For Everyone”, absolutely free when you subscribe to the OpenLampTech newsletter.
MySQL ALTER TABLE
In MySQL, to add a new column to an existing table, the ALTER TABLE syntax would look like this:
ALTER TABLE table_name ADD COLUMN column_name column_definition;
Let’s try adding multiple columns in one command.
I have this arbitrary table with 2 columns:
DESC a_tab;
☕☕☕
If you found value in this post, you can show your appreciation and buy me a coffee. It is my favorite drink!
☕☕☕
We start with ALTER TABLE table_name ADD COLUMN like normal. Then specify however many columns we want, with the required definition for each, enclosed in parentheses.
ALTER TABLE a_tab
ADD COLUMN (
name_col VARCHAR(30) DEFAULT 'not sure',
age_col INTEGER DEFAULT NULL,
another_col TEXT
);
Checking the table definition again, we can see the 3 new columns have been added, all with one ALTER TABLE command:
DESC a_tab;
Viola. So easy, right?
Discover premium articles, in-depth guides, instructional videos, and much more by joining the “MySQL Learning Tier” membership. You have access to exclusive content unpublished anywhere else with this membership. With new content being added regularly, continue learning MySQL at any level.
Thank you for reading this post. Please share it with someone else who would enjoy it as well.
Josh Otwell has a passion to grow as a PHP Developer, SQL expert, and technical blogger/writer.
Disclaimer: The majority of examples in this post, are performed in a personal development/learning workstation environment and should not be considered production quality or ready. Your particular goals and needs may vary. Like always, just because you can do something doesn’t mean you should. My opinions are my own.
Check out this article from the OpenLampTech publication page, Book Recommendation – SQL Antipatterns.
More ways I can help
- Need hosting for your next web application or WordPress site? I highly recommend Hostinger and use them to host my niche bass fishing site. The service is second to none.
- 🔒5 Truths I’ve Come To Realize As a Self-taught Developer
- Desktop and mobile wallpapers, digital downloads, photography services, Shopify and WooCommerce customizations, and content writing – all in one E-commerce Shop. Find your next digital purchase today!
- Take your Laravel applications next level with Battle Ready Laravel by Ash Allen. Learn how to improve the performance, maintainability, and security of your Laravel projects in this e-book.
Disclosure: Some of this blog post’s services and product links are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.
The Newsletter for PHP and MySQL Developers
Receive a copy of my ebook, “10 MySQL Tips For Everyone”, absolutely free when you subscribe to the OpenLampTech newsletter.
Disclosure: Some of this blog post’s services and product links are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.
Support my content with a Tip. Thank you so much!!!
The Newsletter for PHP and MySQL Developers
Receive a copy of my ebook, “10 MySQL Tips For Everyone”, absolutely free when you subscribe to the OpenLampTech newsletter.