Hi,
I will explain DELETE Statement in Oracle SQL in this post of Oracle SQL Tutorial series.
Read the previous post of this tutorial series before this.
The Delete statement is popular command of Oracle SQL and You can delete any existing record in a table using Delete Statement.
DELETE Syntax
Delete statement syntax is as follows.
DELETE FROM table_name WHERE condition;
Delete employee that employee id is 100
SQL> select EMPLOYEE_ID,FIRST_NAME,LAST_NAME,SALARY from hr.employees where EMPLOYEE_ID=100; EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY ----------- -------------------- ------------------------- ---------- 100 MEHMET SALIH DEVECI 30000 SQL> delete from hr.employees where EMPLOYEE_ID=100; 1 row deleted. SQL> commit; Commit complete. SQL> select EMPLOYEE_ID,FIRST_NAME,LAST_NAME,SALARY from hr.employees where EMPLOYEE_ID=100; no rows selected SQL>
Delete All Records
SQL> select * from hr.departments;
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------
10 Administration 200 1700
20 Marketing 201 1800
30 Purchasing 114 1700
40 Human Resources 203 2400
50 Shipping 121 1500
60 IT 103 1400
70 Public Relations 204 2700
80 Sales 145 2500
90 Executive 100 1700
100 Finance 108 1700
110 Accounting 205 1700
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------
120 Treasury 1700
130 Corporate Tax 1700
140 Control And Credit 1700
150 Shareholder Services 1700
160 Benefits 1700
170 Manufacturing 1700
180 Construction 1700
190 Contracting 1700
200 Operations 1700
210 IT Support 1700
220 NOC 1700
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------
230 IT Helpdesk 1700
240 Government Sales 1700
250 Retail Sales 1700
260 Recruiting 1700
270 Payroll 1700
11 Computer Engineering 201 1700
2010 IT TUTORIAL
29 rows selected.
SQL> SQL> delete from hr.departments;
29 rows deleted.
SQL> commit;
Commit complete.
SQL> select * from hr.departments;
no rows selected
SQL>
Do you want to learn Oracle Database for Beginners, then read the following articles.
Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )