SQL - DCL (GRANT and REVOKE)
SQL - DCL (GRANT and REVOKE)
1
Database
Security and Privacy
FUNDAMENTALS OF DATABASE SYSTEMS- SIXTH EDITION – CHAPTER 24
2
Threats to Databases
3
Loss of integrity
4
Loss of availability
5
Loss of confidentiality
6
Access Control
7
Database Security Mechanisms
• Types of database security mechanisms:
• Discretionary Access Control (DAC)
• Grant users to access specific data tables, rows, and columns in a specific mode (select,
insert, delete, and update)
• GRANT and REVOKE privileges
• Mandatory Access Control (MAC)
• Classify the data and the users into different security classes. Various security policy is
enforced to users in different classification level.
• Role Based Access Control (RBAC)
• Roles are assigned to the database.
• Roles have certain permissions on specific data.
8
Discretionary Security Mechanisms
• Grant privileges on a database objects:
10
CONNECT Permission
• Database Administrator must first define a user by granting CONNECT
permission to logon to Oracle:
CREATE USER dbs211a01 IDENTIFIED BY userpassword
GRANT CONNECT TO dbs211a01;
11
Privileges
• The privileges granted to an account determine which
operations the account can perform.
• Privileges differ in the contexts in which they apply and at
different levels of operation:
• Administrative Privileges
• The administrative privileges are global.
• Database Privileges
• The user has privileges for specific databases.
• Database Objects Privileges
• Defines the user privileges to database objects such as tables, indexes, views,
and stored routines. It can be on all database objects or some specific objects.
12
Access Privileges
• The owner of an object may grant another user permission to perform
database operations (ALTER, SELECT, UPDATE, DELETE, INSERT, ALL)
on an object within the owner’s schema :
GRANT ALL ON employee TO dbs211a03;
GRANT SELECT ON employee TO dbs211a04;
• read-only users have no ability to lock rows in the tables they query.
GRANT READ ON employee TO dbs211a03;
13
Grant
• Grant privileges to users
GRANT privileges ON object TO user;
14
Grant Example
15
Revoke
Example:
REVOKE DELETE ON users FROM dbs211a03;
REVOKE INSERT,UPDATE ON users FROM dbs211a03;
REVOKE ALL ON users FROM dbs211a03;
16
PUBLIC Role
• A role is a named group of related privileges that you grant, as a
group, to users or other roles.
• Roles are useful for quickly and easily granting permissions to users.
• PUBLIC role is accessible to every database user.
• All privileges and roles granted to PUBLIC are accessible to every
database user.
SELECT *
FROM user_tab_privs;
SELECT *
FROM user_col_privs;
SELECT *
FROM user_role_privs; 18