Posts

Showing posts from October, 2017

What is a View in oracle?

View in Oracle A view in Oracle database is simply a SELECT query that is given a name and stored in memory for later use. A view can be made joining one or more table and later be queried like a virtual table. How to Create a View Suppose we have the following query. SELECT customerid , customername FROM customers WHERE countryid = 'US' ; Now we can create a view with this query as follows CREATE VIEW us_customers AS SELECT customerid , customername FROM customers WHERE countryid = 'US'; Now, this view can be used instead of the full query SELECT customerid , customername FROM us_customers WHERE customerId > 50 ; Oracle will transform the query into following one SELECT * FROM ( select customerid , customername from customers WHERE countryid = 'US' ) WHERE customerid BETWEEN 100 AND 200 How to Update a View To update a view we can use CREATE OR REPLACE VIEW statement to update a view CREATE OR REPLACE VI