• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / statement / DELETE Statement in Oracle SQL – PLSQL

DELETE Statement in Oracle SQL – PLSQL

October 23, 2012 by techhoneyadmin

The DELETE statement in Oracle SQL / PLSQL allows us to delete record(s) in a table.

Syntax for the DELETE statement in Oracle SQL / PLSQL is:

DELETE FROM table_name
WHERE conditions;

Let’s take an example for understanding:
Suppose have a table named ‘employee’ in the database as shown below.

Employee_ID Employee_Name Salary Department Commission
101 Emp A 10000 Sales 10
102 Emp B 20000 IT 20
103 Emp C 28000 IT 20
104 Emp D 30000 Support
105 Emp E 32000 Sales 10

Scenario 1:

Suppose we want to delete the employee having employee_id = 105 from the ‘employee’ table.
The same can be achieved using the DELETE statement as follows

DELETE FROM employee
WHERE employee_id = 105;

The above statement will delete record from the table where employee_id = 105

Now if we query the ‘employee’ table as;

SELECT *
FROM employee;

We will get the following result:

Employee_ID Employee_Name Salary Department Commission
101 Emp A 10000 Sales 10
102 Emp B 20000 IT 20
103 Emp C 28000 IT 20
104 Emp D 30000 Support

Here we can see that a record with employee_id = 105 has been successfully deleted from the ‘employee’ table.


Scenario 2:

Deleting more than one record at a time in an already existing table:
Let’s assume that we have a new table namely ‘employee’ as shown below:

Employee_ID Employee_Name Salary Department Commission
101 Emp A 10000 Sales 10
102 Emp B 20000 IT 20
103 Emp C 28000 IT 20
104 Emp D 30000 Support
105 Emp E 32000 Sales 10

Here we can see that we have 2 employees in the ‘Sales’ department and we want to delete them.
We can achieve the same as:

DELETE FROM employee
WHERE department = 'Sales';

Once we have run the above code we can query the ‘employee’ table and the following will be the result:

Employee_ID Employee_Name Salary Department Commission
102 Emp B 20000 IT 20
103 Emp C 28000 IT 20
104 Emp D 30000 Support

Here we have successfully deleted the desired records from ‘employee’ table in one shot.


Filed Under: statement Tagged With: DELETE statement in oracle plsql, delete statement in oracle sql, DELETEPLSQL, how to use delete statement in oracle database query, how to use delete statement in oracle plsql, how to use delete statement in oracle sql, syntax and example of delete statement in oracle database query, syntax and example of delete statement in oracle plsql, syntax and example of delete statement in oracle sql, using delete statement in oracle database query, using delete statement in oracle plsql, using delete statement in oracle sql

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in