In Oracle, DELETE statement is used to remove or delete a single record or multiple records from a table.
Syntax
DELETE FROM table_name
WHERE conditions;
1) table_name: It specifies the table which you want to delete.
2) conditions: It specifies the conditions that must met for the records to be deleted.
Example:
DELETE FROM students
WHERE name = 'Rosy';
Output
1 row(s) deleted.
This statement will delete all records from the students table where sname is "Rosy".
In above table,there is not student named "Rosy".
TRUNCATE TABLE
In Oracle, TRUNCATE TABLE statement is used to remove all records from a table.
It works same as DELETE statement but without specifying a WHERE clause.
Syntax
TRUNCATE TABLE [schema_name.]table_name
Example:
TRUNCATE TABLE students;
Output:
Table truncated.
Difference between DELETE TABLE and TRANCATE TABLE
main difference is that you can roll back the DELETE statement whereas you can't roll back the TRUNCATE TABLE statement.
Thank you for reading.