0% found this document useful (0 votes)
9 views7 pages

8.3 Getting Started With SQL Views

Uploaded by

jodoaus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views7 pages

8.3 Getting Started With SQL Views

Uploaded by

jodoaus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

VIEW

VIEW

A VIEW is a virtual table that is based on the result set of a SQL query. It provides a way to encapsulate and
reuse complex queries, simplify data access, and improve security by restricting access to specific data.

order_table
OrderID Amount CustomerID Product ID
view
123 32.000 101 2
OrderID Amount CustomerID Product ID
212 12.500 102 2
123 32.000 Dung Meat
231 21.000 102 1
212 12.500 Hieu Meat

customer_table product_table 231 21.000 Hieu Cake

CustomerID Name Birth ProductID ProductName

101 Dung 1995 1 Cake

102 Hieu 1990 2 Meat


BENEFITS OF VIEW

Simplify
Complex Queries
Instead of writing a
complex join or subquery
multiple times, you can
define it once in a view
and reference the view.
BENEFITS OF VIEW
customer_table

CustomerID Nam Birth Email Address Job

Enhance Security 101 Dung 1995 [email protected] TP.HCM Freelancer

102 Hieu 1990 [email protected] Binh Dinh Data Analyst

Views can be used to


103 Hoa 1999 [email protected] Ha Noi Audit
restrict access to specific
data. You can grant users
access to a view without
giving them direct access customer_view
to the underlying tables.
CustomerID Nam Birth

101 Dung 1995

102 Hieu 1990

103 Hoa 1999


BENEFITS OF VIEW

Simplify Enhance Security Data Abstraction


Complex Queries
Instead of writing a Views can be used to Users can interact with the
complex join or subquery restrict access to specific view without needing to
multiple times, you can data. You can grant users know the details of the
define it once in a view access to a view without underlying table
and reference the view. giving them direct access structures.
to the underlying tables.
BENEFITS OF VIEW

Consistency and
Reusability
Using views helps ensure
consistency in your queries
and promotes reusability.
You can define a complex
query once and use it in
multiple places through the
view.
VIEW: Syntax
Syntax

CREATE VIEW --ViewName AS DROP VIEW --ViewName


-- SQL statement query

CREATE VIEW SimpleEmployeeView AS


Example SELECT EmployeeID, FirstName, LastName
FROM Employees;

You might also like