How do I delete a column from an existing MySQL table using UNIX / Windows / Linux mysql command line utility sql syntax?
You need to use the ALTER TABLE syntax to change the structure of an existing table. For example, you can add or delete columns, create or destroy indexes, change the type of existing columns, and much more with ALTER TABLE.
Step # 1: Login to mysql
Type the following command:
mysql -u user -p databasename
Step 2: Delete column
First see table description:
desc tableName
Use the following syntax at mysql>
ALTER TABLE tableName DROP columnName;
For example, see t1 table description, enter:
DESC t1;Sample outputs:
+-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | c1 | int(11) | YES | | NULL | | | c2 | varchar(30) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.00 sec)
Delete column c2, enter:
ALTER TABLE t1 DROP c2; DESC t1
Sample outputs:
+-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | c1 | int(11) | YES | | NULL | | +-------+---------+------+-----+---------+-------+ 1 row in set (0.00 sec)
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- My 10 UNIX Command Line Mistakes
- Linux: 20 Iptables Examples For New SysAdmins

- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Facebook it - Tweet it - Print it -

