Dropping Tables


To drop a table, use the DROP TABLE command followed by the name of the table. Beware that a dropped table cannot be recovered unless you have a backup.

To drop the people table you created earlier in this lesson, use the following command:

 mysql> DROP TABLE people; Query OK, 0 rows affected (0.00 sec) 


You can use DROP TABLE IF EXISTS so that no error occurs if a table does not exist. This is useful in a batch script that creates all the tables for a database: The script will delete the existing tables before re-creating them but will not fall over if the tables do not exist yet.




Sams Teach Yourself MySQL in 10 Minutes
Sams Teach Yourself MySQL in 10 Minutes
ISBN: 0672328631
EAN: 2147483647
Year: 2006
Pages: 165
Authors: Chris Newman

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net