fastread homefastrread library fastread menu

SQL : DROP TABLE Statement

Tutorial by:Sweta      Date: 2016-04-14 23:49:36

❰ Previous Next ❱

This SQL tutorial explains how to use the SQL DROP TABLE statement with syntax and examples.

Description

The SQL DROP TABLE statement allows you to remove or delete a table from the SQL database.

Syntax

The syntax for the SQL DROP TABLE statement is:

DROP TABLE table_name;

Parameters or Arguments

table_name
The name of the table to remove from the database.

Example

You may have found that you've created a table that you no longer require. You can use the DROP TABLE statement to remove the table from your database.

Let's look at an example that shows how to drop a table using the DROP TABLE statement.

For example:

DROP TABLE suppliers;

This DROP TABLE statement example would drop the table called suppliers. This would both remove the records associated with the suppliers table as well as its table definition.

Once you have dropped the table, you can recreate the suppliers table without getting an error that the table already exists.

Let's look at one more example where we prefix the table name with the database name.

For example:

DROP TABLE totn.contacts;

In this example, e have dropped a table called contacts that is in the totn database.

TIP: It is sometimes easier to drop a table and recreate it, instead of using the ALTER TABLE statement to change the table's definition.

❰ Previous Next ❱