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.

Similar Reads

Set Up an Environment

To understand How To Use PL SQL Insert, Update, Delete, And Select Statement we need a table on which we will perform various operations and queries. Here we will consider a table called students as shown below:...

1. Using INSERT Statement

INSERT statement in the PL/SQL is used to add the new records or rows of data into the table. It allows u to specify the table name, columns where the data will be inserted and the corresponding values to be inserted into the columns....

2. Using UPDATE Statement

UPDATE statement in the PL/SQL is used to the modify the existing records in table. It is allowed us to specify the table name, columns to updated new values for these columns and an optional conditional to the filter which rows are to be updated....

Examples on UPDATE Statement

Example 1:...

3. Using DELETE Statement

DELETE statement in the PL/SQL is used to remove the one or more records from the table. It is allowed you to the specify the table name and optional condition to the filter which rows are to be deleted....

Examples on DELETE Statement

Example 1:...

4. Using SELECT Statement

SELECT statement in the PL/SQL is used to the retrieve the data from one or more tables. It is allowed you to the specify the columns you want to be retrieve, table from the which you want to be retrieve the data and optional condition to filter rows retrieved....

Example on SELECT statements

SELECT student_id, first_nameFROM students;...

Conclusion

Overall, We have learned the essential concepts and syntax for the using PL/SQL INSERT, UPDATE, DELETE and SELECT statements in Oracle databases. By the understanding of the fundamentals of SQL operations, you can be effectively manipulate and query the data within the Oracle databases using the PL/SQL. Whether you are adding the new data, updating the existing records, deleting the unwanted entries or retrieving the information these statements provide the necessary tools for the managing the database content....