DROP SQL with examples


    • Syntax
    • Use cases
    • sample query


The DROP TABLE command in SQL allows you to permanently drop a table from a database. This removes at the same time the possible indexes, triggers, constraints and permissions associated with this table.

Warning: this command must be used with care because once deleted, the data is lost. Before using it in any significant way, it may be wise to make a backup to avoid any unpleasant surprises.


To drop a table “table_name” simply use the following syntax :

DROP TABLE nombre_de_tabla

NOTE if there is a dependency with another table, it is recommended to remove them before dropping the table. This is the case, for example, if there are alien/foreign keys.

Use cases

Sometimes a table is created temporarily to store data that is not intended to be reused. Deleting an unused table is advantageous in several ways:

  • release memory and lighten the burden of backups.
  • Avoid errors in the future if a table has a similar or confusing name.
  • When a developer or database administrator starts developing a new application, it is faster to understand the system if only the used tables are present.

sample query

Imagine that a database has a table “client_2009” that will never be used again and already exists in an old backup. To delete this table, you just need to do the following query:

DROP TABLE cliente_2009

Running this query you will delete immediately and irreversibly the indicated table.

Leave a Reply