Oracle DELETE Statement

In Oracle, DELETE statement is used to delete the existing records in a table. Condition specified in WHERE clause decides the number of records being deleted. After deleting records we need to commit using COMMIT statement to permanently save the data. We can use rollback command to undo the update statement changes.

Syntax to delete records

DELETE FROM <table-name> [WHERE condition];

COMMIT;

It is very import to include WHERE clause in the delete statement, if no WHERE clause is specified then all records will be deleted;

Example to delete records

 

CREATE TABLE EMPLOYEE(EMPLOYEE_ID NUMBER(5), NAME VARCHAR2(30), SALARY NUMBER (6));

 

INSERT INTO EMPLOYEE VALUES(101,'Manu',1000);

 

INSERT INTO EMPLOYEE VALUES(102,'Advith',2000);

 

COMMIT;

 

---------Delete selected records-------------

 

DELETE FROM EMPLOYEE;

 

DELETE FROM EMPLOYEE WHERE NAME = Advith;

 

COMMIT;

 

---------Delete all records-------------

DELETE FROM EMPLOYEE;

 

COMMIT;

 

 

 

← Previous - UpdateNext - Transaction →
By Manu Manjunatha
Author

Dear Reader, I created this site to help students and professionals learn software technologies. I am committed to provide easy and detailed tutorials. I hope you see all that reflected in the tutorials. I am happy to hear your comments and get your feedback on how I am doing. Some errors may have accidentally crept in the tutorials despite my hard work. Please send me your valuable feedback from here Contact Us .
Follow the fun here: