DELETE: The SQL DELETE command is a DML (Data Manipulation Language) command that deletes existing records from the table in the database. It can delete one or more rows from the table depending on the condition given with the WHERE clause. Thus the deletion of data is controlled according to the user's needs and requirements. The DELETE statement does not delete the table from the database. It just deletes the records present inside it and maintains a transaction log of each deleted row.
Syntax: DELETE FROM TableName WHERE condition;
DROP: The SQL DROP command is a DDL (Data Definition Language) command that deletes the defined table with all its table data, associated indexes, constraints, triggers, and permission specifications. The DROP command drops the existing table from the database. It only requires the name of the table to be dropped.
Syntax: DROP TABLE table_name;
Difference between DELETE and DROP command of SQL are as follows:
Parameters |
DELETE Command |
DROP Command |
Language |
The DELETE command is Data Manipulation Language Command. |
The DROP command is Data Definition Language Command. |
Use |
The DELETE command deletes one or more existing records from the table in the database. |
The DROP Command drops the complete table from the database. |
Transition |
We can restore any deleted row or multiple rows from the database using the ROLLBACK command. |
We cannot get the complete table deleted from the database using the ROLLBACK command. |
Memory Space |
The DELETE command does not free the allocated space of the table from memory. |
The DROP command removes the space allocated for the table from memory. |
Performance Speed |
The DELETE command performs slower than the DROP command and TRUNCATE command as it deletes one or more rows based on a specific condition. |
The DROP Command has faster performance than DELETE Command but not as compared to the Truncate Command because the DROP command deletes the table from the database after deleting the rows. |
Integrity Constraints |
The Integrity Constraints remain the same in the DELETE command. |
The Integrity Constraints get removed for the DROP command. |
Permission |
DELETE permission is required to delete the rows of the table. |
We need ALTER permission on the schema to which the table belongs and CONTROL permission on the table to use the DROP command. |
Syntax |
DELETE FROM table_name WHERE condition; |
DROP TABLE table_name; |