How To Delete an Existing Column in a Table?
Submitted by: AdministratorIf you have an existing column in a table and you do not need that column any more, you can delete it with "ALTER TABLE ... DROP COLUMN" statement. Here is a tutorial script to delete an existing column:
mysql> ALTER TABLE tip DROP COLUMN create_date;
Query OK, 1 row affected (0.48 sec)
Records: 1 Duplicates: 0 Warnings: 0
<pre>mysql> SELECT * FROM tip;
+----+-------------+-------------------------+--------+
| id | subject | description | author |
+----+-------------+-------------------------+--------+
| 1 | Learn MySQL | Visit www.GlobalGuideLine.com | NULL |
+----+-------------+-------------------------+--------+</pre>
1 row in set (0.00 sec)
As you can see the column "create_date" is gone.
Submitted by: Administrator
mysql> ALTER TABLE tip DROP COLUMN create_date;
Query OK, 1 row affected (0.48 sec)
Records: 1 Duplicates: 0 Warnings: 0
<pre>mysql> SELECT * FROM tip;
+----+-------------+-------------------------+--------+
| id | subject | description | author |
+----+-------------+-------------------------+--------+
| 1 | Learn MySQL | Visit www.GlobalGuideLine.com | NULL |
+----+-------------+-------------------------+--------+</pre>
1 row in set (0.00 sec)
As you can see the column "create_date" is gone.
Submitted by: Administrator
Read Online MySQL Programming Job Interview Questions And Answers
Top MySQL Programming Questions
☺ | How To Use Regular Expression in Pattern Match Conditions? |
☺ | What Is TIMESTAMP in MySQL? |
☺ | How To Enter Numeric Values as HEX Numbers? |
☺ | What Is View? |
☺ | How To Use CASE Expression? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |