Loading lesson path
Concept visual
Start at both ends
statement is used to permanently delete an existing table in a database.
Be careful before dropping a table! Dropping a table deletes the entire table and all its content!
table_name
;
To prevent an error from occur (if the table does not exists), it is a good practice to add the IF EXISTSclause:
table_name
;In most databases you cannot drop a table that is referenced by a foreign key constraint in another table. To solve this, you must remove the foreign key constraint or drop the dependent table.
The following SQL statement drops the "Shippers" table:
DROP TABLE IF EXISTS Shippers;statement is used to delete all the records in a table, but it keeps the table structure, columns and constraints.
table_name
;