MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Drop Table

MySQL Drop TABLE statement remove the existing table from database. The DROP TABLE statement not only removes a table but also remove its structure and data permanently from the database. In MySQL, you can remove multiple tables using a single DROP TABLE statement, each table is separated by a comma (,).

Note: You must have DROP privileges for the table that you want to remove.

MySQL DROP TABLE Syntax

To remove existing table, use the following syntax:

Syntax

DROP [TEMPORARY] TABLE [IF EXISTS] tablename [, table_name] ...

Parameters:

oldtablename: The old table name that you want to rename.

newtablename: The new table name for the existing table.

[TEMPORARY]: The TEMPORARY flag allows you to remove temporary tables only.

[IF EXISTS]: The IF EXISTS helps you to prevent from removing non-existent tables.

MySQL Drop TABLE example

The following MySQL statement to remove existing table:

Example

DROP TABLE IF EXISTS tblCustomer;

Note:

In the above example, we removed the existing table "tblCustomer" from database.

You can use MySQL Command Line Client to remove existing table. It will look like this:

Check REMOVED TABLE

You can check the removed table by the following query:

Example

SHOW tables;  

You can use MySQL Command Line Client to show renamed table name. It will look like this: