Removing Record from a Table


☞ Following are the topics to be covered :

1. Delete particular record.
2. Delete all records.
3. Truncate command.
4. Difference between Delete and Truncate statement.

☞ To remove record from a table in RDBMS, we use DELETE command.

☞ It is used to delete the record from a table.

Syntax :

DELETE FROM <table_name>
WHERE <condition>;

Delete particular record

Example :

DELETE FROM Student
WHERE Rollno=10;

Delete all records

Example :

DELETE FROM Student;
Note :
1. WHERE clause is optional.
2. It identifies the record that get deleted.

SQL TRUNCATE Command

☞ It is used to delete all the records from a table.

☞ It free the space containing the table for reuse.

Syntax :

TRUNCATE TABLE <table_name>;

Example :

TRUNCATE TABLE Student;

Difference between DELETE and TRUNCATE Statements

S.No.DELETE StatementTRUNCATE Statement
1.It is used to delete only the rows from a table. It is used to delete all the rows from the table based on given condition.
2. It does not free up the space contating the table. It free the space containing the table for reuse.