Oracle: Update VIEW

The creation of the VIEW is what we have studied in the previous article. Now, in this article, we are going to learn about how we can UPDATE an already created VIEW. 

Syntax

Create OR REPLACE VIEW VIEW_NAME as
New_query;

Conside the Stu Table as below:

Stu Table

Previously, we created a VIEW named Less_Than that contains a query:

SELECT * from Stu
where Roll_No <20;

However now we want to change the query that contains all the values of Stu table where Roll_no>20.

That task can be performed using CREATE OR REPLACE VIEW Keyword followed by View name in Oracle.

Example

We have a View Last_name is mentioned above as:

LAST_NAME

Now we want to alter the values and store only those values into the Last_Name that have Roll_No in Stu Table more than 20.

We can perform the task by the code shown as below:

Create OR REPLACE VIEW Less_than as
Select * from Stu where Roll_No>20;

Output
Update view

Now, below you can find the updated view that contains values > 20.

select_view