MySQL Programming Question: Download Questions PDF
How To Rename an Existing Table in MySQL?
Answer:
If you want to rename an existing table, you can use the "ALTER TABLE ... RENAME TO" statement. The tutorial script below shows you a good example:
mysql> ALTER TABLE tip RENAME TO faq;
Query OK, 0 rows affected (0.01 sec)
<pre>mysql> SELECT * FROM faq;
+----+-------------+-------------------------+--------+
| id | title | description | author |
+----+-------------+-------------------------+--------+
| 1 | Learn MySQL | Visit www.GlobalGuideLine.com | NULL |
+----+-------------+-------------------------+--------+</pre>
1 row in set (0.00 sec)
mysql> ALTER TABLE tip RENAME TO faq;
Query OK, 0 rows affected (0.01 sec)
<pre>mysql> SELECT * FROM faq;
+----+-------------+-------------------------+--------+
| id | title | description | author |
+----+-------------+-------------------------+--------+
| 1 | Learn MySQL | Visit www.GlobalGuideLine.com | NULL |
+----+-------------+-------------------------+--------+</pre>
1 row in set (0.00 sec)
Download MySQL Programming Interview Questions And Answers
PDF
Previous Question | Next Question |
How To Rename an Existing Column in a Table? | How To Drop an Existing Table in MySQL? |