Informatics Practices · Ch 7 — Introduction to Structured Query Language (SQL)
DROP Statement
7.4.5
DROP Statement
Sometimes a table in a database — or the database itself — needs to be removed altogether. The DROP statement does this: it removes a database or a table permanently from the system. The word permanently is the one to take seriously — a DROP cannot be undone, so the statement demands real caution before it is executed.
Syntax to drop a table:
DROP TABLE table_name;
Syntax to drop a database:
DROP DATABASE database_name;
Watch out
Two cautions before using DROP:
- Using the DROP statement to remove a database will ultimately remove all the tables within it — every relation, and all their records, disappear along with the container.
- DROP will remove the tables or database that you have created — so while practising, it is wise to apply DROP only at the end of the chapter, after all the work with StudentAttendance is finished. …