☰ See All Chapters |
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;
|
All Chapters