Examples on UPDATE Statement
Example 1:
Let’s update the last name of the students as Anderson whose student_id is 3.
UPDATE students
SET last_name = 'Anderson'
WHERE student_id = 3;
Output:
student_id |
first_name |
last_name |
---|---|---|
1 |
John |
Doe |
2 |
Jane |
Smith |
3 |
Michael |
Anderson |
4 |
Emily |
Williams |
Explanation:
- Execute the above UPDATE statement in your SQL client for update the last_name of the student with the student_id 3 to Anderson.
Example 2:
Let’s update the first name of the students as Mitch whose student_id is 3.
UPDATE students
SET first_name = 'Mitch'
WHERE student_id = 3;
Output:
student_id |
first_name |
last_name |
---|---|---|
1 |
John |
Doe |
2 |
Jane |
Smith |
3 |
Mitch |
Anderson |
4 |
Emily |
Williams |
Explanation of the Code:
- Execute the above UPDATE statement in your SQL client for update the first_name of the student with the student_id 3 to Mitch.
How to Use PL SQL Insert, Update, Delete And Select Statement?
PL/SQL is a powerful extension of SQL specifically designed for Oracle databases. It enables developers to create procedural logic and execute SQL commands within Oracle database environments. In this article, we will explore the usage of fundamental PL/SQL statements such as INSERT, UPDATE, DELETE and SELECT with he help of various examples which are essential for manipulating data in Oracle databases.