SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

What's New In MySQL 5.6
What's New In MySQL 5.6What's New In MySQL 5.6
What's New In MySQL 5.6Abdul Manaf
 
mysql 1st. act.
mysql 1st. act.mysql 1st. act.
mysql 1st. act.von lozano
 
Sql Queries
Sql QueriesSql Queries
Sql Querieswebicon
 
Optimizing Queries with Explain
Optimizing Queries with ExplainOptimizing Queries with Explain
Optimizing Queries with ExplainMYXPLAIN
 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQLEvan Weaver
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016Mir Mahmood
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle databaseSalman Memon
 
Oracle Web Adi For upload item master
Oracle Web Adi For upload item masterOracle Web Adi For upload item master
Oracle Web Adi For upload item masterAhmed Elshayeb
 
Warranty management system
Warranty management systemWarranty management system
Warranty management systemMoin Raza Khan
 
MYSQL single rowfunc-multirowfunc-groupby-having
MYSQL single rowfunc-multirowfunc-groupby-havingMYSQL single rowfunc-multirowfunc-groupby-having
MYSQL single rowfunc-multirowfunc-groupby-havingAhmed Farag
 
MYSQL using set operators
MYSQL using set operatorsMYSQL using set operators
MYSQL using set operatorsAhmed Farag
 

La actualidad más candente (15)

What's New In MySQL 5.6
What's New In MySQL 5.6What's New In MySQL 5.6
What's New In MySQL 5.6
 
Sql ch 13 - sql-views
Sql ch 13 - sql-viewsSql ch 13 - sql-views
Sql ch 13 - sql-views
 
mysql 1st. act.
mysql 1st. act.mysql 1st. act.
mysql 1st. act.
 
Sql Queries
Sql QueriesSql Queries
Sql Queries
 
Optimizing Queries with Explain
Optimizing Queries with ExplainOptimizing Queries with Explain
Optimizing Queries with Explain
 
Efficient Pagination Using MySQL
Efficient Pagination Using MySQLEfficient Pagination Using MySQL
Efficient Pagination Using MySQL
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
MySQL Views
MySQL ViewsMySQL Views
MySQL Views
 
MYSql manage db
MYSql manage dbMYSql manage db
MYSql manage db
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle database
 
Oracle Web Adi For upload item master
Oracle Web Adi For upload item masterOracle Web Adi For upload item master
Oracle Web Adi For upload item master
 
Warranty management system
Warranty management systemWarranty management system
Warranty management system
 
MYSQL single rowfunc-multirowfunc-groupby-having
MYSQL single rowfunc-multirowfunc-groupby-havingMYSQL single rowfunc-multirowfunc-groupby-having
MYSQL single rowfunc-multirowfunc-groupby-having
 
MYSQL using set operators
MYSQL using set operatorsMYSQL using set operators
MYSQL using set operators
 

Destacado

Destacado (20)

Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
Fundamentals
FundamentalsFundamentals
Fundamentals
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
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
 
3. elements
3. elements3. elements
3. elements
 
Exceptions
ExceptionsExceptions
Exceptions
 
Get excelsheet
Get excelsheetGet excelsheet
Get excelsheet
 
Forms
FormsForms
Forms
 
Interface connection
Interface connectionInterface connection
Interface connection
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Headings
HeadingsHeadings
Headings
 
Different waysconnect
Different waysconnectDifferent waysconnect
Different waysconnect
 
Driver
DriverDriver
Driver
 
Record store
Record storeRecord store
Record store
 

Similar a Views

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
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsmaxpane
 

Similar a Views (20)

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
 
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
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactions
 
View
ViewView
View
 

Más de myrajendra

Más de myrajendra (16)

Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Internal
InternalInternal
Internal
 
2. attributes
2. attributes2. attributes
2. attributes
 
Css
CssCss
Css
 
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
 
Indexing
IndexingIndexing
Indexing
 
Get data
Get dataGet data
Get data
 

Último

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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Último (20)

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
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Views

  • 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