Let’s Create Some View
Let’s Create a view named `products_list` that includes `product_id`, `product_name`, and `price` from the `products` table, and then select all data from this view.
CREATE OR REPLACE VIEW products_list AS
SELECT product_id, product_name, price
FROM
products;
select * from products_list;
Output:
product_id |
product_name |
price |
---|---|---|
1 |
Laptop |
12000 |
2 |
Mobilephone |
11500 |
3 |
Headset |
750 |
4 |
pens |
100 |
Explanation:The above output shows the details of products_list view.
Let’s Create another view named `expensive_products` that includes `product_id`, `product_name`, and `price` from the `products` table where the `price` is greater than 1000, and then select all data from this view.
CREATE OR REPLACE VIEW expensive_products AS
SELECT product_id, product_name, price
FROM
products
WHERE price > 1000;
select * from expensive_products;
Output:
product_id |
product_name |
price |
---|---|---|
1 |
Laptop |
12000 |
2 |
Mobilephone |
11500 |
Explanation:The above output shows the items which price is more than 1000.
PL/SQL DROP VIEW
Views serve as an important tool for simplifying complex queries, enhancing data security, and streamlining database management. They provide a virtual layer that presents data from underlying tables in a structured format. However, views like other database objects need to be managed effectively to maintain data integrity and optimize performance
In this article, We will learn about the PL/SQL DROP VIEW by understanding the various examples with the output in detail.