Skip to content
Related Articles

Related Articles

Improve Article

Difference between DELETE and DROP in SQL

  • Last Updated : 19 Aug, 2019

Prerequisite – SQL Commands
DELETE is a Data Manipulation Language (DML) command and used when you want to remove some or all the tuples from a relation. If WHERE clause is used along with the DELETE command it removes only those tuples which satisfy the WHERE clause condition but if WHERE clause is missing from the DELETE statement then by default all the tuples present in relation are removed.

The syntax of DELETE command:

DELETE FROM relation_name 
WHERE condition;

DROP is a Data Definition Language (DDL) command which removes the named elements of the schema like relations, domains or constraints and you can also remove an entire schema using DROP command.

The syntax of DROP command:

DROP SCHEMA schema_name RESTRICT;
DROP Table table_name CASCADE;

Comparison Chart:

ParameterDELETEDROP
BasicIt removes some or all the tuples from a table.It removes entire schema, table, domain, or constraints from the database.
LanguageData Manipulation Language commandData Definition Language command.
ClauseWHERE clause mainly used along with the DELETE command.No clause required along with DROP command.
RollbackActions performed by DELETE can be rolled back as it uses buffer.Actions performed by DROP can’t be rolled back because it directly works on actual data.
Spacespace occupied by the table in the memory is not freed even if you delete all the tuples of the table using DELETEIt frees the table space from memory
Main IssueShortage of memoryMemory fragmentation
Locality of referenceExcellentAdequate
FlexibilityFixed sizeResizing is possible

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :