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:

MariaDB> 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.

Previous Page Next Page