T-SQL Drop-Table

The DROP TABLE statement in T-SQL is used to remove the table definition and remove the data, indexes, triggers, constraints of the table.

Note- We need to use this command carefully because if we delete a table by using this command then all the data stored in the table will be lost forever.

Syntax of Drop-Table

The syntax of the DROP TABLE statement is-

Example:

Firstly, verify the CUSTOMERS table, and then delete it from the database-

The above command generates the following table.

TABLE_QUALIFIER   TABLE_OWNER   TABLE_NAME   COLUMN_NAME   DATA_TYPE   TYPE_NAME
   PRECISION   LENGTH SCALE   RADIX   NULLABLE   REMARKS   COLUMN_DEF   SQL_DATA_TYPE 
   SQL_DATETIME_SUB   CHAR_OCTET_LENGTH   ORDINAL_POSITION   IS_NULLABLE   SS_DATA_TYPE

TestDB    dbo    CUSTOMERS   ID        4   int        10 4 0 10 0     
NULL      NULL   4   NULL    NULL      1   NO         56 

TestDB    dbo    CUSTOMERS   NAME     12 varchar 20 20 NULL NULL0   
 NULL     NULL   12   NULL   20        2   NO        39

TestDB    dbo    CUSTOMERS   AGE       4   int        10 4 0 10 0
 NULL     NULL   4   NULL    NULL      3   NO         56 

TestDB    dbo    CUSTOMERS   ADDRESS   1   char 25 25 NULL NULL 1 
 NULL     NULL   1   NULL    25        4   YES        39  

TestDB    dbo    CUSTOMERS   SALARY   3   decimal    18 20 2 10 1  
 NULL     NULL   3   NULL    NULL     5   YES         106 

CUSTOMERS table is available in the database, so let's drop it. Below is the command:

Command (s) completed.

With the above command, we have not received any row.

No any data is displayed here as table is deleted.

We will explain the Create Statement in T-SQL in the next page.