DROP TABLE (U-SQL)

Summary

The statement drops the specified table and deletes all the data contained within from the system.

Warning

This operation cannot be undone!

Syntax

Drop_Table_Statement :=                                                                                  
    'DROP' 'TABLE' ['IF' 'EXISTS'] Identifier.

Remarks

  • Identifier
    Identifies the table to be dropped. If the Identifier is a three-part identifier, the table will be dropped from the specified database and schema. If the Identifier is a two-part identifier, then the table of the given schema and of the given name of the current static database context will be dropped. If the identifier is a simple identifier, then the table of the given name in the current static database and schema context will be dropped.

    If a table of the given name does not exist, or the user has no permissions to drop the table, an error is raised.

  • IF EXISTS
    If the optional IF EXISTS is specified, then the statement drops the table if it already exists, or succeeds without changes if the table does not exist or the user has no permission to at least enumerate all existing tables.

Examples

  • The example can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
  • The script can be executed locally. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.

The following script shows how the SampleTable in the TestReferenceDB database’s default schema is deleted if it already exists before it is recreated:

DROP TABLE IF EXISTS TestReferenceDB..SampleTable;  
  
CREATE TABLE TestReferenceDB..SampleTable AS (id int);  

See Also