SQL DROP Table

From WikiOD

Remarks[edit | edit source]

DROP TABLE removes the table definition from the schema along with the rows, indexes, permissions, and triggers.

Check for existence before dropping[edit | edit source]

MySQL3.19

DROP TABLE IF EXISTS MyTable;

PostgreSQL8.x

DROP TABLE IF EXISTS MyTable;

SQL Server2005

If Exists(Select * From Information_Schema.Tables
          Where Table_Schema = 'dbo'
            And Table_Name = 'MyTable')
  Drop Table dbo.MyTable

SQLite3.0

DROP TABLE IF EXISTS MyTable;

Simple drop[edit | edit source]

Drop Table MyTable;

Credit:Stack_Overflow_Documentation