SlideShare une entreprise Scribd logo
1  sur  8
VIEW
•

•

•
•
•
•
•
•

VIEW is a virtual table, which acts like a table but actually it contains no data. That
is based on the result set of a SELECT statement. A VIEW consists rows and
columns from one or more than one tables. A VIEW is a query that?s stored as an
object. A VIEW is nothing more than a way to select a subset of table?s columns.
When you defined a view then you can reference it like any other table in a
database. A VIEW provides as a security mechanism also. VIEWS ensures that users
are able to modify and retrieve only that data which seen by them.
By using Views you can ensure about the security of data by restricting access to
the following data:
Specific columns of the tables.
Specific rows of the tables.
Specific rows and columns of the tables.
Subsets of another view or a subset of views and tables
Rows fetched by using joins.
Statistical summary of data in a given tables.
CREATE VIEW Statement
•

•
•
•
•
•
•

CREATE VIEW Statement is used to create a new database view. The general
syntax of CREATE VIEW Statement is:
CREATE VIEW view_name [(column_list)] [WITH ENCRYPTION] AS
select_statement [WITH CHECK OPTION]
View_name specifies the name for the new view.
column_list specifies the name of the columns to be used in view.
column_list must have the same number of columns that specified in
select_statement. If column_list option is not available then view is created
with the same columns that specified in select_statement.
WITH ENCRYPTION option encrypts the text to the view in the syscomments
table.
AS option specifies the action that is performed by the view.
select_statement is used to specify the SELECT statement that defines a view.
The optional WITH CHECK OPTION clause applies to the data modification
statement like INSERT and UPDATE statements to fulfill the criteria given in the
select_statement defining the view. This option also ensures that the data can
visible after the modifications are made permanent.
Rules for views
• A view can be created only in the current database.
• The view name must follow the rules for identifiers and
• The view name must not be the same as that of the base
table
• A view can be created only that time if there is a SELECT
permission on its base table.
• A SELECT INTO statement cannot be used in view
declaration statement.
• A trigger or an index cannot be defined on a view.
• The CREATE VIEW statement cannot be combined with
other SQL statements in a single batch.
•

•

•

Example :
In the following example we have two table Client and Products. And if you want to see only those
client records that are active in Products table also means right now they are supplying us the
products. For this we are creating the view by the name of Supp_Client.
mysql> SELECT * FROM Client; +------+---------------+----------+ | C_ID | Name | City | +------+--------------+----------+ | 1 | A K Ltd | Delhi | | 2 | V K Associate | Mumbai | | 3 | R K India | Banglore | | 4 | R
S P Ltd | Kolkata | | 5 | A T Ltd | Delhi | | 6 | D T Info | Delhi | +------+---------------+----------+ 6 rows
in set (0.00 sec) mysql> SELECT * FROM Products; +---------+-------------+------+ | Prod_ID |
Prod_Detail | C_ID | +---------+-------------+------+ | 111 | Monitor | 1 | | 112 | Processor | 2 | | 113 |
Keyboard | 2 | | 114 | Mouse | 3 | | 115 | CPU | 5 | +---------+-------------+------+ 5 rows in set (0.00
sec)
Example : Create View Statement
mysql> CREATE VIEW Supp_Client AS -> SELECT * FROM Client -> WHERE C_ID IN ( -> SELECT
C_ID FROM Products) -> WITH CHECK OPTION; Query OK, 0 rows affected (0.05 sec) mysql>
SELECT * FROM Supp_Client; +------+---------------+----------+ | C_ID | Name | City | +------+--------------+----------+ | 1 | A K Ltd | Delhi | | 2 | V K Associate | Mumbai | | 3 | R K India | Banglore | | 5 | A
T Ltd | Delhi | +------+---------------+----------+ 4 rows in set (0.03 sec) In the following example we
include the WHERE clause with the select statement of view. Then MySQL adds this condition to
the VIEW definition when executing the statement for further restricting the result. Example :
mysql> SELECT * FROM Supp_Client WHERE City='Delhi'; +------+---------+-------+ | C_ID | Name |
City | +------+---------+-------+ | 1 | A K Ltd | Delhi | | 5 | A T Ltd | Delhi | +------+---------+-------+ 2
rows in set (0.04 sec)
ALTER VIEW Statement
•

•

•

•

By the ALTER VIEW Statement we can change the definition of a view. This
statement is useful to modify a view without dropping it. ALTER VIEW statement
syntax is similar to CREATE VIEW Statement and effect is same as the CREATE OR
REPLACE VIEW. The general syntax of ALTER VIEW Statement is :
ALTER VIEW view_name [(column_list)] [WITH ENCRYPTION] AS
select_statement [WITH CHECK OPTION]
In the following example we are altering the view definition that we have created
above. In this we add one more column by the name of Prod_Detail of Products
table. Example of Altering the View Statement :
mysql> ALTER VIEW Supp_Client AS -> SELECT
Client.C_ID, Client.Name, Client.City, -> Products.Prod_Detail from
Client, Products -> WHERE Client.C_ID=Products.C_ID; Query OK, 0 rows affected
(0.01 sec)
mysql> SELECT * FROM Supp_Client; +------+---------------+----------+-------------+ |
C_ID | Name | City | Prod_Detail | +------+---------------+----------+-------------+ | 1 | A
K Ltd | Delhi | Monitor | | 2 | V K Associate | Mumbai | Processor | | 2 | V K
Associate | Mumbai | Keyboard | | 3 | R K India | Banglore | Mouse | | 5 | A T Ltd
| Delhi | CPU | +------+---------------+----------+-------------+ 5 rows in set (0.02 sec)
DROP VIEW Statement
• For dropping a view you can use the DROP VIEW
Statement. When view is dropped but it has no
effect on the underlying tables. After dropping a
view if you issue any query that reference a
dropped view then you get an error message. But
dropping a table that reference any view does not
drop the view automatically you have to dropt
the view explicitly. The general syntax of DROP
VIEW Statement is :
• DROP VIEW view_name;
• In the following example we are dropping the
view that we have created above. Example of
Dropping the View Statement :
• mysql> DROP VIEW Supp_Client; Query OK, 0
rows affected (0.00 sec) mysql> SELECT *
FROM Supp_Client; ERROR 1146 (42S02):
Table 'employee.supp_client' doesn't exist

Contenu connexe

Tendances

Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayimtiazalijoono
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureA. N. M. Jubaer
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort AlgorithmLemia Algmri
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship setMegha Sharma
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSAjunnubabu
 
Presentation on array
Presentation on array Presentation on array
Presentation on array topu93
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 
Applications of stack
Applications of stackApplications of stack
Applications of stackeShikshak
 
structure and union
structure and unionstructure and union
structure and unionstudent
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its typesRameesha Sadaqat
 
Operating system and its function
Operating system and its functionOperating system and its function
Operating system and its functionNikhi Jain
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxEllenGrace9
 

Tendances (20)

Trigger
TriggerTrigger
Trigger
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
trigger dbms
trigger dbmstrigger dbms
trigger dbms
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
heap Sort Algorithm
heap  Sort Algorithmheap  Sort Algorithm
heap Sort Algorithm
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
Degree of relationship set
Degree of relationship setDegree of relationship set
Degree of relationship set
 
Priority queue in DSA
Priority queue in DSAPriority queue in DSA
Priority queue in DSA
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Data types
Data typesData types
Data types
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Applications of stack
Applications of stackApplications of stack
Applications of stack
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Singly link list
Singly link listSingly link list
Singly link list
 
structure and union
structure and unionstructure and union
structure and union
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 
Operating system and its function
Operating system and its functionOperating system and its function
Operating system and its function
 
Data Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
 

En vedette (20)

Views
ViewsViews
Views
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
Forms
FormsForms
Forms
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
Css
CssCss
Css
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Views
ViewsViews
Views
 
Fundamentals
FundamentalsFundamentals
Fundamentals
 
Scan scheduling 50 1
Scan scheduling 50 1Scan scheduling 50 1
Scan scheduling 50 1
 
C scan scheduling 50 2
C scan scheduling 50 2C scan scheduling 50 2
C scan scheduling 50 2
 
Look scheduling.51
Look scheduling.51Look scheduling.51
Look scheduling.51
 
C look scheduling 51 1
C look scheduling 51 1C look scheduling 51 1
C look scheduling 51 1
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Get excelsheet
Get excelsheetGet excelsheet
Get excelsheet
 
Class
ClassClass
Class
 
Wr ex2
Wr ex2Wr ex2
Wr ex2
 
Class
ClassClass
Class
 
Exceptions
ExceptionsExceptions
Exceptions
 

Similaire à VIEWS allow secure access to data

Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL IISankhya_Analytics
 
chap 7.ppt(sql).ppt
chap 7.ppt(sql).pptchap 7.ppt(sql).ppt
chap 7.ppt(sql).pptarjun431527
 
Designing and Creating Views, Inline Functions, and Synonyms
 Designing and Creating Views, Inline Functions, and Synonyms Designing and Creating Views, Inline Functions, and Synonyms
Designing and Creating Views, Inline Functions, and SynonymsTayba Farooqui
 
Implementing views
Implementing views Implementing views
Implementing views sqlschoolgr
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objectsSyed Zaid Irshad
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)Valeriy Kravchuk
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data RedactionAlex Zaballa
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)Dave Stokes
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Mydbops
 
Data Redaction - OTN TOUR LA 2015
Data Redaction - OTN TOUR LA 2015 Data Redaction - OTN TOUR LA 2015
Data Redaction - OTN TOUR LA 2015 Alex Zaballa
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptFramgia Vietnam
 

Similaire à VIEWS allow secure access to data (20)

View
ViewView
View
 
Getting Started with MySQL II
Getting Started with MySQL IIGetting Started with MySQL II
Getting Started with MySQL II
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
Chap 7
Chap 7Chap 7
Chap 7
 
Les11
Les11Les11
Les11
 
chap 7.ppt(sql).ppt
chap 7.ppt(sql).pptchap 7.ppt(sql).ppt
chap 7.ppt(sql).ppt
 
Module05
Module05Module05
Module05
 
Designing and Creating Views, Inline Functions, and Synonyms
 Designing and Creating Views, Inline Functions, and Synonyms Designing and Creating Views, Inline Functions, and Synonyms
Designing and Creating Views, Inline Functions, and Synonyms
 
Sql ch 13 - sql-views
Sql ch 13 - sql-viewsSql ch 13 - sql-views
Sql ch 13 - sql-views
 
Lec 09 SQL - 3.pptx
Lec 09 SQL - 3.pptxLec 09 SQL - 3.pptx
Lec 09 SQL - 3.pptx
 
Implementing views
Implementing views Implementing views
Implementing views
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objects
 
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
MariaDB 10.5 new features for troubleshooting (mariadb server fest 2020)
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.Modern query optimisation features in MySQL 8.
Modern query optimisation features in MySQL 8.
 
Data Redaction - OTN TOUR LA 2015
Data Redaction - OTN TOUR LA 2015 Data Redaction - OTN TOUR LA 2015
Data Redaction - OTN TOUR LA 2015
 
View, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - ThaiptView, Store Procedure & Function and Trigger in MySQL - Thaipt
View, Store Procedure & Function and Trigger in MySQL - Thaipt
 
Les10
Les10Les10
Les10
 

Plus de myrajendra

Plus de myrajendra (17)

Data type
Data typeData type
Data type
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
Headings
HeadingsHeadings
Headings
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 
Properties
PropertiesProperties
Properties
 
Java.sql package
Java.sql packageJava.sql package
Java.sql package
 
Interface callable statement
Interface callable statementInterface callable statement
Interface callable statement
 
Interface result set
Interface result setInterface result set
Interface result set
 
Interface database metadata
Interface database metadataInterface database metadata
Interface database metadata
 
Interface connection
Interface connectionInterface connection
Interface connection
 
Indexing
IndexingIndexing
Indexing
 
Get data
Get dataGet data
Get data
 
Driver
DriverDriver
Driver
 

Dernier

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 

Dernier (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 

VIEWS allow secure access to data

  • 2. • • • • • • • • VIEW is a virtual table, which acts like a table but actually it contains no data. That is based on the result set of a SELECT statement. A VIEW consists rows and columns from one or more than one tables. A VIEW is a query that?s stored as an object. A VIEW is nothing more than a way to select a subset of table?s columns. When you defined a view then you can reference it like any other table in a database. A VIEW provides as a security mechanism also. VIEWS ensures that users are able to modify and retrieve only that data which seen by them. By using Views you can ensure about the security of data by restricting access to the following data: Specific columns of the tables. Specific rows of the tables. Specific rows and columns of the tables. Subsets of another view or a subset of views and tables Rows fetched by using joins. Statistical summary of data in a given tables.
  • 3. CREATE VIEW Statement • • • • • • • CREATE VIEW Statement is used to create a new database view. The general syntax of CREATE VIEW Statement is: CREATE VIEW view_name [(column_list)] [WITH ENCRYPTION] AS select_statement [WITH CHECK OPTION] View_name specifies the name for the new view. column_list specifies the name of the columns to be used in view. column_list must have the same number of columns that specified in select_statement. If column_list option is not available then view is created with the same columns that specified in select_statement. WITH ENCRYPTION option encrypts the text to the view in the syscomments table. AS option specifies the action that is performed by the view. select_statement is used to specify the SELECT statement that defines a view. The optional WITH CHECK OPTION clause applies to the data modification statement like INSERT and UPDATE statements to fulfill the criteria given in the select_statement defining the view. This option also ensures that the data can visible after the modifications are made permanent.
  • 4. Rules for views • A view can be created only in the current database. • The view name must follow the rules for identifiers and • The view name must not be the same as that of the base table • A view can be created only that time if there is a SELECT permission on its base table. • A SELECT INTO statement cannot be used in view declaration statement. • A trigger or an index cannot be defined on a view. • The CREATE VIEW statement cannot be combined with other SQL statements in a single batch.
  • 5. • • • Example : In the following example we have two table Client and Products. And if you want to see only those client records that are active in Products table also means right now they are supplying us the products. For this we are creating the view by the name of Supp_Client. mysql> SELECT * FROM Client; +------+---------------+----------+ | C_ID | Name | City | +------+--------------+----------+ | 1 | A K Ltd | Delhi | | 2 | V K Associate | Mumbai | | 3 | R K India | Banglore | | 4 | R S P Ltd | Kolkata | | 5 | A T Ltd | Delhi | | 6 | D T Info | Delhi | +------+---------------+----------+ 6 rows in set (0.00 sec) mysql> SELECT * FROM Products; +---------+-------------+------+ | Prod_ID | Prod_Detail | C_ID | +---------+-------------+------+ | 111 | Monitor | 1 | | 112 | Processor | 2 | | 113 | Keyboard | 2 | | 114 | Mouse | 3 | | 115 | CPU | 5 | +---------+-------------+------+ 5 rows in set (0.00 sec) Example : Create View Statement mysql> CREATE VIEW Supp_Client AS -> SELECT * FROM Client -> WHERE C_ID IN ( -> SELECT C_ID FROM Products) -> WITH CHECK OPTION; Query OK, 0 rows affected (0.05 sec) mysql> SELECT * FROM Supp_Client; +------+---------------+----------+ | C_ID | Name | City | +------+--------------+----------+ | 1 | A K Ltd | Delhi | | 2 | V K Associate | Mumbai | | 3 | R K India | Banglore | | 5 | A T Ltd | Delhi | +------+---------------+----------+ 4 rows in set (0.03 sec) In the following example we include the WHERE clause with the select statement of view. Then MySQL adds this condition to the VIEW definition when executing the statement for further restricting the result. Example : mysql> SELECT * FROM Supp_Client WHERE City='Delhi'; +------+---------+-------+ | C_ID | Name | City | +------+---------+-------+ | 1 | A K Ltd | Delhi | | 5 | A T Ltd | Delhi | +------+---------+-------+ 2 rows in set (0.04 sec)
  • 6. ALTER VIEW Statement • • • • By the ALTER VIEW Statement we can change the definition of a view. This statement is useful to modify a view without dropping it. ALTER VIEW statement syntax is similar to CREATE VIEW Statement and effect is same as the CREATE OR REPLACE VIEW. The general syntax of ALTER VIEW Statement is : ALTER VIEW view_name [(column_list)] [WITH ENCRYPTION] AS select_statement [WITH CHECK OPTION] In the following example we are altering the view definition that we have created above. In this we add one more column by the name of Prod_Detail of Products table. Example of Altering the View Statement : mysql> ALTER VIEW Supp_Client AS -> SELECT Client.C_ID, Client.Name, Client.City, -> Products.Prod_Detail from Client, Products -> WHERE Client.C_ID=Products.C_ID; Query OK, 0 rows affected (0.01 sec) mysql> SELECT * FROM Supp_Client; +------+---------------+----------+-------------+ | C_ID | Name | City | Prod_Detail | +------+---------------+----------+-------------+ | 1 | A K Ltd | Delhi | Monitor | | 2 | V K Associate | Mumbai | Processor | | 2 | V K Associate | Mumbai | Keyboard | | 3 | R K India | Banglore | Mouse | | 5 | A T Ltd | Delhi | CPU | +------+---------------+----------+-------------+ 5 rows in set (0.02 sec)
  • 7. DROP VIEW Statement • For dropping a view you can use the DROP VIEW Statement. When view is dropped but it has no effect on the underlying tables. After dropping a view if you issue any query that reference a dropped view then you get an error message. But dropping a table that reference any view does not drop the view automatically you have to dropt the view explicitly. The general syntax of DROP VIEW Statement is :
  • 8. • DROP VIEW view_name; • In the following example we are dropping the view that we have created above. Example of Dropping the View Statement : • mysql> DROP VIEW Supp_Client; Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM Supp_Client; ERROR 1146 (42S02): Table 'employee.supp_client' doesn't exist