Teradata DROP TABLE

Teradata DROP TABLE statement removes an existing table along with the data and table structure from the Teradata database. The table structure is removed from the data dictionary table. After successful completion of the command, data along with the table structure is lost permanently.

Once the table is dropped, the data and table structure cannot be recovered. So, we need to make sure that we are in the correct database before issuing the DROP TABLE statement.

You should have DROP privileges on the table in order to drop the table.

Teradata DROP TABLE syntax

The syntax of the Teradata DROP TABLE is as follows.

DROP TABLE database_name.table_name;

Here,

  • database_name – The name of the parent database where the table resides.
  • table_name – The name of the table you want to drop.

Teradata DROP TABLE Example

You can drop a Teradata table in two ways.

Method 1:

The following statement drops the student_details table from the tutorialsbook database. Here, we have proved a fully qualified table name i.e. along with the database name.

DROP TABLE tutorialsbook.student_details;

Output:

DROP TABLE tutorialsbook.student_details;

 *** Table has been dropped.
 *** Total elapsed time was 1 second.

Method 2:

In the second method, first, select the owner database and then issue the DROP TABLE statement.

DATABASE tutorialsbook;
DROP TABLE student_details;

Output:

DATABASE tutorialsbook;

 *** New default database accepted.
 *** Total elapsed time was 1 second.


 BTEQ -- Enter your SQL request or BTEQ command:
DROP TABLE student_details;

DROP TABLE student_details;

 *** Table has been dropped.
 *** Total elapsed time was 1 second.

The same table name can be present in different databases. So, we need to make sure that we have selected the correct database before executing the DROP TABLE statement.

Please get connected & share!

Advertisement