Lesson: Managing Roles
Lesson: Managing Roles
Lesson: Managing Roles
Managing Roles
MAS-CS352-DBMS2
Lesson Objectives:
After completing this lesson, the student should be
able to:
Create a new USER
Grant Privilege access to a specific User.
Changes password
Create and Grant role
Pass Privileges
Revoke Privileges
MAS-CS352-DBMS2
Controlling User Access
MAS-CS352-DBMS2
Controlling User Access cont.
In a multiple-user environment, you want to maintain security of the
database access and use. With Oracle server database security,
you can do the following:
Control database access
Give access to specific objects in the database
Confirm given and received privileges with the Oracle data dictionary
Create synonyms for database objects
Database security can be classified into two categories: system
security and data security.
System security covers access and use of the database at the system
level such as the username and password, the disk space allocated to
users, and the system operations that users can perform.
Database security covers access and use of the database objects and
the actions that those users can have on the objects.
MAS-CS352-DBMS2
Privileges
Database security:
System security
Data security
System privileges: Gaining access to the
database
Object privileges: Manipulating the content
of the database objects
Schemas: Collection of objects such as
tables, views, and sequences
MAS-CS352-DBMS2
System Privileges
More than 100 privileges are available.
The database administrator has high-level
system privileges for tasks such as:
Creating new users
Removing users
Removing tables
Backing up tables
MAS-CS352-DBMS2
Creating Users
The DBA creates users with the CREATE USER
statement.
Syntax:
CREATE USER user_name
IDENTIFIED BY user_password;
Example:
MAS-CS352-DBMS2
User System Privileges
After a user is created, the DBA can grant specific system
privileges to that user.
Syntax:
GRANT PRIVILEGE [privilege_type….]
TO user_name [,user| role, PUBLIC…];
An application developer, for example, may have the following
system privileges:
CREATE SESSION
CREATE TABLE
CREATE SEQUENCE
CREATE VIEW
CREATE PROCEDURE
MAS-CS352-DBMS2
User System Privileges
The DBA can grant specific system privileges to a user.
Example:
MAS-CS352-DBMS2
User System Privileges: cont.
Supposed that a user TIGER with a password of TIGER with a
privilege of creating a session only.
When this user try to create a table which is not granted as shown in
the example:
MAS-CS352-DBMS2
What Is a Role?
MAS-CS352-DBMS2
What Is a Role?
What Is a Role?
A role is a named group of related privileges that can be granted to the user. This
method makes it easier to revoke and maintain privileges.
A user can have access to several roles, and several users can be assigned the
same role. Roles are typically created for a database application.
Creating and Assigning a Role
First, the DBA must create the role. Then the DBA can assign privileges to the
role and assign the role to users.
Syntax
MAS-CS352-DBMS2
Creating and Granting Privileges to a Role
MAS-CS352-DBMS2
Changing Your Password
The DBA creates your user account and initializes your password.
You can change your password by using the ALTER USER
statement.
Example:
Try to exit isqlplus* then log-on using IT_MGR with the new
password MGR.
MAS-CS352-DBMS2
Object Privileges
MAS-CS352-DBMS2
Object Privileges: cont.
MAS-CS352-DBMS2
Object Privileges: cont.
By granting SELECT on user IT_MGR and tiger, these two users should
used the example below in order to view the values on EMPLOYEES
table:
Where:
SYSTEM: is the original user who grant a SELECT roles to IT_MGR and tiger.
EMPLOYEES: is the name of the table granted to used SELECT statement.
MAS-CS352-DBMS2
Object Privileges: cont.
MAS-CS352-DBMS2
Passing on your Privileges
A privilege that is granted with the WITH GRANT OPTION clause can be
passed on to other users and roles by the grantee. Object privileges granted
with the WITH GRANT OPTION clause are revoked when the grantor’s
privilege is revoked.
The example on the slide gives user TIGER access to EMPLOYEES table
with the privileges to query the table and add rows to the table. The
example also shows that TIGER can give others these privileges.
MAS-CS352-DBMS2
Passing on your Privileges: Specific User
In the example: the user TIGER was able to pass the privilege given
to IT_MGR user.
Since privilege has been passed to user TIGER this user can now
insert a new row to EMPLOYEES table as shown in the example
below:
MAS-CS352-DBMS2
Passing on your Privileges: PUBLIC
MAS-CS352-DBMS2
Confirming Privileges Granted
MAS-CS352-DBMS2
Revoking other Privileges
MAS-CS352-DBMS2
Revoking Object Privileges: Example
MAS-CS352-DBMS2
DELETING AN EXISTING USER
MAS-CS352-DBMS2
Lesson Summary:
In this lesson, you should have learned about statements that control
access to the database and database objects.
Create new user using CREATE USER user and is usually
performed by the Database Admin
Grant specific privileges either Private or Public using the GRANT
option.
Create specific privileges by using the CREATE ROLE
Change password created by using the ALTER USER statement
Removes privileges on an object by using the REVOKE statement
MAS-CS352-DBMS2