SlideShare a Scribd company logo
DBMS Security
In This Lecture
• Database Security
• Aspects of security
• Access to databases
• Privileges and views
• Database Integrity
• View updating, Integrity constraints
Database Security
• Database security is
about controlling
access to
information
• Some information
should be available
freely
• Other information
should only be
available to certain
people or groups
• Many aspects to
consider for security
• Legal issues
• Physical security
• OS/Network security
• Security policies and
protocols
• Encryption and
passwords
• DBMS security
DBMS Security Support
• DBMS can provide
some security
• Each user has an
account, username
and password
• These are used to
identify a user and
control their access to
information
• DBMS verifies
password and checks
a user’s permissions
when they try to
• Retrieve data
• Modify data
• Modify the database
structure
Permissions and Privilege
• SQL uses privileges
to control access to
tables and other
database objects
• SELECT privilege
• INSERT privilege
• UPDATE privilege
• DELETE privilege
• The owner (creator)
of a database has all
privileges on all
objects in the
database, and can
grant these to others
• The owner (creator)
of an object has all
privileges on that
object and can pass
them on to others
Privileges in SQL
GRANT <privileges>
ON <object>
TO <users>
[WITH GRANT OPTION]
• <privileges> is a list of
SELECT <columns>,
INSERT <columns>,
DELETE, and
UPDATE <columns>, or
simply ALL
• <users> is a list of user
names or PUBLIC
• <object> is the name of
a table or view (later)
• WITH GRANT OPTION
means that the users can
pass their privileges on
to others
Privileges Examples
GRANT ALL ON Employee
TO Manager
WITH GRANT OPTION
The user ‘Manager’ can do
anything to the Employee
table, and can allow other
users to do the same (by
using GRANT statements)
GRANT SELECT,
UPDATE(Salary) ON
Employee TO Finance
The user ‘Finance’ can view
the entire Employee table,
and can change Salary
values, but cannot change
other values or pass on
their privilege
Removing Privileges
• If you want to
remove a privilege
you have granted
you use
REVOKE <privileges>
ON <object>
FROM <users>
• If a user has the
same privilege from
other users then
they keep it
• All privileges
dependent on the
revoked one are also
revoked
Removing Privileges
• Example
• ‘Admin’ grants ALL
privileges to ‘Manager’,
and SELECT to
‘Finance’ with grant
option
• ‘Manager’ grants ALL to
Personnel
• ‘Finance’ grants
SELECT to Personnel
Admin
Finance Manager
Personnel
SELECT
SELECT
ALL
ALL
ALL
SELECT
SELECT
Removing Privileges
Admin
Finance Manager
Personnel
ALL
• Manager’ revokes ALL
from ‘Personnel’
• ‘Personnel’ still has
SELECT privileges from
‘Finance’
• ‘Admin’ revokes
SELECT from ‘Finance’
• Personnel loses SELECT
also
Views
• Privileges work at
the level of tables
• You can restrict
access by column
• You cannot restrict
access by row
• Views, along with
privileges, allow for
customised access
• Views provide
‘derived’ tables
• A view is the result of
a SELECT statement
which is treated like a
table
• You can SELECT from
(and sometimes
UPDATE etc) views
just like tables
View Example
• Example
• We want each user to be able to view the names and
phone numbers (only) of those employees in their
own department
• In Oracle, you can refer to the current user as USER
Employee
ID Name Phone Department Salary
E158 Mark x6387 Accounts £15,000
E159 Mary x6387 Marketing £15,000
E160 Jane x6387 Marketing £15,000
View Example
CREATE VIEW OwnDept AS
SELECT Name, Phone FROM Employee
WHERE Department =
(SELECT Department FROM Employee
WHERE name = USER)
GRANT SELECT ON OwnDept TO PUBLIC
Using Views and Privileges
Conceptual
View
External
View 1
External
View 2
User 1 User 2 User 3
DBA
• Views and privileges
are used together to
control access
• A view is made which
contains the
information needed
• Privileges are granted
to that view, rather
than the underlying
tables
View Updating
• Views are like virtual
tables
• Their value depends
on the ‘base’ tables
that they are defined
from
• You can select from
views just like a table
• What about update,
insert, and delete?
• Updating views
• Updates to the base
tables change the
views and vice-versa
• It is often not clear
how to change the
base tables to make
the desired change to
the view
View Updating
• For a view to be updatable, the defining
query of the view should satisfy certain
conditions:
• Every element in SELECT is a column name
• Should not use DISTINCT
• View should be defined on a single table (no
join, union, etc. used in FROM)
• WHERE should not have nested SELECTs
• Should not use GROUP BY or HAVING
Using Views and Privileges
To restrict someone's
access to a table
• Create a view of that
table that shows only
the information they
need to see
• Grant them privileges
on the view
• Revoke any privileges
they have on the
original table
ID Name Salary Department
Employee
• We want to let the
user ‘Omar' read the
department and
name, and be able to
update the
department (only)
Using Views and Privileges
Create a view
CREATE VIEW forOmar
AS SELECT Name, Department
FROM Employee
Set the privileges
GRANT SELECT,
UPDATE (Department)
ON forOmar
TO Omar
REVOKE ALL ON
forOmar FROM Omar

More Related Content

Similar to DBMS Security.ppt

Implementing views
Implementing views Implementing views
Implementing views sqlschoolgr
 
Sharing and security in Salesforce
Sharing and security in SalesforceSharing and security in Salesforce
Sharing and security in SalesforceSaurabh Kulkarni
 
Oracle Database Security For Developers
Oracle Database Security For DevelopersOracle Database Security For Developers
Oracle Database Security For DevelopersSzymon Skorupinski
 
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
 
Controlling User Access -Data base
Controlling User Access -Data baseControlling User Access -Data base
Controlling User Access -Data baseSalman Memon
 
Sql ch 15 - sql security
Sql ch 15 - sql securitySql ch 15 - sql security
Sql ch 15 - sql securityMukesh Tekwani
 
August 12: Sugar’s Security Model – Teams and Roles
August 12: Sugar’s Security Model – Teams and Roles August 12: Sugar’s Security Model – Teams and Roles
August 12: Sugar’s Security Model – Teams and Roles ticomixcrm
 
Clase 18 privilegios modificada
Clase 18 privilegios   modificadaClase 18 privilegios   modificada
Clase 18 privilegios modificadaTitiushko Jazz
 
Clase 18 privilegios modificada
Clase 18 privilegios   modificadaClase 18 privilegios   modificada
Clase 18 privilegios modificadaTitiushko Jazz
 
Incorta Data Security
Incorta Data SecurityIncorta Data Security
Incorta Data SecurityDylan Wan
 
e computer notes - Controlling user access
e computer notes - Controlling user accesse computer notes - Controlling user access
e computer notes - Controlling user accessecomputernotes
 
Presentation database security enhancements with oracle
Presentation   database security enhancements with oraclePresentation   database security enhancements with oracle
Presentation database security enhancements with oraclexKinAnx
 
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbdsfoodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbdsputtipavan23022023
 
Postgresql stored procedure
Postgresql stored procedurePostgresql stored procedure
Postgresql stored procedureJong Woo Rhee
 

Similar to DBMS Security.ppt (20)

6232 b 04
6232 b 046232 b 04
6232 b 04
 
Implementing views
Implementing views Implementing views
Implementing views
 
Oracle Database View
Oracle Database ViewOracle Database View
Oracle Database View
 
Sharing and security in Salesforce
Sharing and security in SalesforceSharing and security in Salesforce
Sharing and security in Salesforce
 
Oracle Database Security For Developers
Oracle Database Security For DevelopersOracle Database Security For Developers
Oracle Database Security For Developers
 
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
 
Les14
Les14Les14
Les14
 
8034.ppt
8034.ppt8034.ppt
8034.ppt
 
Controlling User Access -Data base
Controlling User Access -Data baseControlling User Access -Data base
Controlling User Access -Data base
 
Sql ch 15 - sql security
Sql ch 15 - sql securitySql ch 15 - sql security
Sql ch 15 - sql security
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
August 12: Sugar’s Security Model – Teams and Roles
August 12: Sugar’s Security Model – Teams and Roles August 12: Sugar’s Security Model – Teams and Roles
August 12: Sugar’s Security Model – Teams and Roles
 
Clase 18 privilegios modificada
Clase 18 privilegios   modificadaClase 18 privilegios   modificada
Clase 18 privilegios modificada
 
Clase 18 privilegios modificada
Clase 18 privilegios   modificadaClase 18 privilegios   modificada
Clase 18 privilegios modificada
 
Incorta Data Security
Incorta Data SecurityIncorta Data Security
Incorta Data Security
 
VIEWS.pptx
VIEWS.pptxVIEWS.pptx
VIEWS.pptx
 
e computer notes - Controlling user access
e computer notes - Controlling user accesse computer notes - Controlling user access
e computer notes - Controlling user access
 
Presentation database security enhancements with oracle
Presentation   database security enhancements with oraclePresentation   database security enhancements with oracle
Presentation database security enhancements with oracle
 
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbdsfoodmunch 2.pptx hdshid hdbfhdbfhkd vcn  vbds
foodmunch 2.pptx hdshid hdbfhdbfhkd vcn vbds
 
Postgresql stored procedure
Postgresql stored procedurePostgresql stored procedure
Postgresql stored procedure
 

Recently uploaded

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...CzechDreamin
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backElena Simperl
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Alison B. Lowndes
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaRTTS
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 

Recently uploaded (20)

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 

DBMS Security.ppt

  • 2. In This Lecture • Database Security • Aspects of security • Access to databases • Privileges and views • Database Integrity • View updating, Integrity constraints
  • 3. Database Security • Database security is about controlling access to information • Some information should be available freely • Other information should only be available to certain people or groups • Many aspects to consider for security • Legal issues • Physical security • OS/Network security • Security policies and protocols • Encryption and passwords • DBMS security
  • 4. DBMS Security Support • DBMS can provide some security • Each user has an account, username and password • These are used to identify a user and control their access to information • DBMS verifies password and checks a user’s permissions when they try to • Retrieve data • Modify data • Modify the database structure
  • 5. Permissions and Privilege • SQL uses privileges to control access to tables and other database objects • SELECT privilege • INSERT privilege • UPDATE privilege • DELETE privilege • The owner (creator) of a database has all privileges on all objects in the database, and can grant these to others • The owner (creator) of an object has all privileges on that object and can pass them on to others
  • 6. Privileges in SQL GRANT <privileges> ON <object> TO <users> [WITH GRANT OPTION] • <privileges> is a list of SELECT <columns>, INSERT <columns>, DELETE, and UPDATE <columns>, or simply ALL • <users> is a list of user names or PUBLIC • <object> is the name of a table or view (later) • WITH GRANT OPTION means that the users can pass their privileges on to others
  • 7. Privileges Examples GRANT ALL ON Employee TO Manager WITH GRANT OPTION The user ‘Manager’ can do anything to the Employee table, and can allow other users to do the same (by using GRANT statements) GRANT SELECT, UPDATE(Salary) ON Employee TO Finance The user ‘Finance’ can view the entire Employee table, and can change Salary values, but cannot change other values or pass on their privilege
  • 8. Removing Privileges • If you want to remove a privilege you have granted you use REVOKE <privileges> ON <object> FROM <users> • If a user has the same privilege from other users then they keep it • All privileges dependent on the revoked one are also revoked
  • 9. Removing Privileges • Example • ‘Admin’ grants ALL privileges to ‘Manager’, and SELECT to ‘Finance’ with grant option • ‘Manager’ grants ALL to Personnel • ‘Finance’ grants SELECT to Personnel Admin Finance Manager Personnel SELECT SELECT ALL ALL
  • 10. ALL SELECT SELECT Removing Privileges Admin Finance Manager Personnel ALL • Manager’ revokes ALL from ‘Personnel’ • ‘Personnel’ still has SELECT privileges from ‘Finance’ • ‘Admin’ revokes SELECT from ‘Finance’ • Personnel loses SELECT also
  • 11. Views • Privileges work at the level of tables • You can restrict access by column • You cannot restrict access by row • Views, along with privileges, allow for customised access • Views provide ‘derived’ tables • A view is the result of a SELECT statement which is treated like a table • You can SELECT from (and sometimes UPDATE etc) views just like tables
  • 12. View Example • Example • We want each user to be able to view the names and phone numbers (only) of those employees in their own department • In Oracle, you can refer to the current user as USER Employee ID Name Phone Department Salary E158 Mark x6387 Accounts £15,000 E159 Mary x6387 Marketing £15,000 E160 Jane x6387 Marketing £15,000
  • 13. View Example CREATE VIEW OwnDept AS SELECT Name, Phone FROM Employee WHERE Department = (SELECT Department FROM Employee WHERE name = USER) GRANT SELECT ON OwnDept TO PUBLIC
  • 14. Using Views and Privileges Conceptual View External View 1 External View 2 User 1 User 2 User 3 DBA • Views and privileges are used together to control access • A view is made which contains the information needed • Privileges are granted to that view, rather than the underlying tables
  • 15. View Updating • Views are like virtual tables • Their value depends on the ‘base’ tables that they are defined from • You can select from views just like a table • What about update, insert, and delete? • Updating views • Updates to the base tables change the views and vice-versa • It is often not clear how to change the base tables to make the desired change to the view
  • 16. View Updating • For a view to be updatable, the defining query of the view should satisfy certain conditions: • Every element in SELECT is a column name • Should not use DISTINCT • View should be defined on a single table (no join, union, etc. used in FROM) • WHERE should not have nested SELECTs • Should not use GROUP BY or HAVING
  • 17. Using Views and Privileges To restrict someone's access to a table • Create a view of that table that shows only the information they need to see • Grant them privileges on the view • Revoke any privileges they have on the original table ID Name Salary Department Employee • We want to let the user ‘Omar' read the department and name, and be able to update the department (only)
  • 18. Using Views and Privileges Create a view CREATE VIEW forOmar AS SELECT Name, Department FROM Employee Set the privileges GRANT SELECT, UPDATE (Department) ON forOmar TO Omar REVOKE ALL ON forOmar FROM Omar