ORACLE DELETE
To remove or delete a single record or multiple records from a table, Oracle DELETE statement is used.
Syntax: To delete all rows from a table.
DELETE FROM table_name
Syntax: To delete specific rows from a table.
DELETE FROM table_name WHERE conditions;
Parameters:
table_name: It is used to specify the name of the table to be deleted.
conditions: It is used to specify the conditions to be strictly fulfilled for the deletion process to take place.
Example: Deleting one row from a table.
DELETE FROM students WHERE student_age = 10 AND student_id = 1; |
Output:
1 row deleted.
Explanation:
The ‘students’ is an already existing table. The student_age and the student_id are the two columns of the ‘students’ table. Here, we are deleting a row whose student_age is 10 and student_id is 1.
Example: Deleting multiple rows from a table.
DELETE FROM students WHERE student_age = 10 |
Output:
30 rows deleted.
Explanation:
The ‘students’ is an already existing table. The student_age is a column of the ‘students’ table. Here, we are deleting all rows whose student_age is 10.
Example: Deleting all rows from a table.
DELETE FROM students |
Output:
100 rows deleted.
Explanation:
The ‘students’ is an already existing table. Here, we are deleting all rows of the table.