6 User Security And Privilege Management

Database Administration · Unit 6

User Security and Privilege Management

Exam-focused notes for User Security and Privilege Management (Database Administration, BIT352): what the TU syllabus asks and how it has actually been tested, with 9 solved past questions from this unit.

User Security and Privilege Management in short

This chapter shows how a DBA creates users, controls what they can do, and sets password rules. It is the base of database security.

User Security and Privilege Management: notes

User creation and management commands

A user is an account that can connect to the database. Each user owns a schema, which is the set of objects the user creates.

CREATE USER ram IDENTIFIED BY Ram#123
  DEFAULT TABLESPACE users
  TEMPORARY TABLESPACE temp
  QUOTA 50M ON users;

Parts of the command:

  • IDENTIFIED BY sets the password.
  • DEFAULT TABLESPACE is where the user's objects are stored.
  • TEMPORARY TABLESPACE is used for sorting.
  • QUOTA limits the space the user can use.

Manage the user later with ALTER USER.

ALTER USER ram IDENTIFIED BY New#456;
ALTER USER ram ACCOUNT LOCK;
ALTER USER ram ACCOUNT UNLOCK;
ALTER USER ram PASSWORD EXPIRE;
ALTER USER ram QUOTA 100M ON users;

A new user cannot even log in until given the CREATE SESSION privilege. View users with SELECT username, account_status FROM dba_users;.

Privilege definition and importance

A privilege is the right to run a certain SQL statement or to use a certain object. Privileges decide who may do what.

They are important because:

  • They protect data from people who should not see or change it.
  • They support least privilege: only the rights needed for the job.
  • They limit the damage from mistakes and attacks.
  • They make auditing and accountability possible.

What this unit covers

  • User creation and management commands
  • Privilege definition and importance
  • System privileges and object privileges
  • Grant privilege commands
  • Revoke privilege commands
  • Drop user commands
  • Role definition and purpose
  • Role creation and assignment
  • Role in privilege management
  • User profiles and profile assignment

Privilege definition and importance

2081 · 5 marks

What is privilege? Write commands to create user, grant privilege, revoke privilege and drop user in oracle database. [5]

Show solved answer

Privilege in Oracle Database

What is Privilege?

A privilege is a right or permission granted to a database user to perform a specific operation or to access a specific database object. Privileges control what actions a user can perform in the database system.

There are two types of privileges in Oracle:

  • System Privileges - Allow users to perform specific database operations (e.g., CREATE TABLE, CREATE SESSION)
  • Object Privileges - Allow users to perform operations on specific database objects like tables, views, etc. (e.g., SELECT, INSERT, UPDATE, DELETE on a table)

Oracle Database Commands

1. Create User

CREATE USER username IDENTIFIED BY password;

Example:

CREATE USER john IDENTIFIED BY john123;

2. Grant Privilege

GRANT privilege_name TO username;

Example (System Privilege):

GRANT CREATE SESSION TO john;
GRANT CREATE TABLE TO john;

Example (Object Privilege):

GRANT SELECT, INSERT ON employees TO john;

The WITH GRANT OPTION allows the user to further grant the privilege to others:

GRANT SELECT ON employees TO john WITH GRANT OPTION;

3. Revoke Privilege

REVOKE privilege_name FROM username;

Example (System Privilege):

REVOKE CREATE TABLE FROM john;

Example (Object Privilege):

REVOKE SELECT, INSERT ON employees FROM john;

4. Drop User

DROP USER username;

Example:

DROP USER john;

If the user owns database objects (tables, views, etc.), use CASCADE to drop the user along with all their objects:

DROP USER john CASCADE;

Summary Table

OperationCommand Syntax
Create UserCREATE USER name IDENTIFIED BY password;
Grant PrivilegeGRANT privilege TO user;
Revoke PrivilegeREVOKE privilege FROM user;
Drop UserDROP USER name [CASCADE];
Open this answer on its own page →

2080 · 10 marks

What is the importance of privileges in database security? Explain about role in oracle datanse and write command to do following: a. Create role b. Grant system and object privileges to role c. Create user d. Assign role to user e. Drop role[10]

--- Privileges are permissions granted to users that allow them to perform specific operations on a database or its objects. They are fundamental to database security for the following reasons: 1. Access Control: Privileges ensure that only authorized users can access, modify, or delete data, pre...

Open this answer on its own page →

2081.1 · 5 marks

What is privilege? Write commands to create user, grant privilege, revoke privilege and drop user in oracle database. [5]

Show solved answer

Privilege in Oracle Database

What is Privilege?

A privilege is a right or permission granted to a database user to perform a specific operation or to access a specific database object. Privileges control what actions a user can perform in the database system.

There are two types of privileges in Oracle:

  • System Privileges - Allow users to perform specific database operations (e.g., CREATE TABLE, CREATE SESSION)
  • Object Privileges - Allow users to perform operations on specific database objects like tables, views, etc. (e.g., SELECT, INSERT, UPDATE, DELETE on a table)

Oracle Database Commands

1. Create User

CREATE USER username IDENTIFIED BY password;

Example:

CREATE USER john IDENTIFIED BY john123;

2. Grant Privilege

GRANT privilege_name TO username;

Examples:

-- Grant system privilege
GRANT CREATE SESSION TO john;
GRANT CREATE TABLE TO john;

-- Grant object privilege
GRANT SELECT, INSERT ON employees TO john;

-- Grant all privileges
GRANT ALL PRIVILEGES TO john;

The WITH GRANT OPTION allows the user to further grant the privilege to others:

GRANT SELECT ON employees TO john WITH GRANT OPTION;

3. Revoke Privilege

REVOKE privilege_name FROM username;

Examples:

-- Revoke system privilege
REVOKE CREATE TABLE FROM john;

-- Revoke object privilege
REVOKE SELECT, INSERT ON employees FROM john;

4. Drop User

DROP USER username;

Example:

DROP USER john;

-- To drop user along with all their objects (tables, views, etc.)
DROP USER john CASCADE;

The CASCADE option is used when the user owns database objects; it removes the user and all associated objects.


Summary Table

OperationCommand
Create UserCREATE USER name IDENTIFIED BY password;
Grant PrivilegeGRANT privilege TO user;
Revoke PrivilegeREVOKE privilege FROM user;
Drop UserDROP USER name [CASCADE];
Open this answer on its own page →

0 · 5 marks

What is privilege? Write commands to create user, grant privilege, revoke privilege and drop user in oracle database. [5]

Show solved answer

Privilege in Oracle Database

What is Privilege?

A privilege is a right or permission granted to a database user to perform a specific action on the database or on a specific database object. Privileges control what a user can do within the Oracle database system.

There are two types of privileges in Oracle:

  • System Privileges - Allow users to perform specific actions on the database (e.g., CREATE TABLE, CREATE SESSION).
  • Object Privileges - Allow users to perform specific actions on specific database objects like tables, views, sequences (e.g., SELECT, INSERT, UPDATE, DELETE on a table).

Oracle Database Commands

1. Create User

CREATE USER username IDENTIFIED BY password;

Example:

CREATE USER john IDENTIFIED BY john123;

2. Grant Privilege

GRANT privilege_name TO username;

Example (System Privilege):

GRANT CREATE SESSION TO john;
GRANT CREATE TABLE TO john;

Example (Object Privilege):

GRANT SELECT, INSERT ON employees TO john;

The WITH GRANT OPTION allows the user to further grant the privilege to others:

GRANT SELECT ON employees TO john WITH GRANT OPTION;

3. Revoke Privilege

REVOKE privilege_name FROM username;

Example (System Privilege):

REVOKE CREATE TABLE FROM john;

Example (Object Privilege):

REVOKE SELECT, INSERT ON employees FROM john;

4. Drop User

DROP USER username;

Example:

DROP USER john;

If the user owns database objects (tables, views, etc.), use CASCADE to drop the user along with all their objects:

DROP USER john CASCADE;

Summary Table

OperationCommand Syntax
Create UserCREATE USER name IDENTIFIED BY password;
Grant PrivilegeGRANT privilege TO user;
Revoke PrivilegeREVOKE privilege FROM user;
Drop UserDROP USER name [CASCADE];
Open this answer on its own page →

Role definition and purpose

2081 · 5 marks

What is Role? Explain its role in privilege management with suitable example. [5]

A role is a named collection of privileges (permissions) that can be granted to users or other roles. Instead of assigning individual privileges directly to each user, privileges are grouped into a role, and that role is then assigned to users who need those privileges. Note: The reference notes ...

Open this answer on its own page →

2081.1 · 5 marks

What is Role? Create a Role called “general” and grant privileges to the role general and assign that role to a user in oracle. [5]

A Role is a named group of related privileges that can be granted to users or other roles. Instead of granting individual privileges to each user separately, a DBA can grant multiple privileges to a role and then assign that role to multiple users. This simplifies privilege management in Oracle d...

Open this answer on its own page →

0 · 5 marks

What is Role? Explain its role in privilege management with suitable example. [5]

A role is a named collection of privileges (permissions) that can be granted to users or other roles. Instead of assigning individual privileges directly to each user, privileges are grouped into a role, and that role is then assigned to users who need those privileges. Note: The reference notes ...

Open this answer on its own page →

User profiles and profile assignment

2081 · 5 marks

What is user profile? Create a simple user profile and assign the profile to new user in oracle. [5]

A user profile in Oracle is a named set of resource limits and password management parameters that can be assigned to one or more database users. It controls and restricts the use of database resources such as CPU time, logical reads, sessions, and also enforces password policies like expiry, reu...

Open this answer on its own page →

0 · 5 marks

What is user profile? Create a simple user profile and assign the profile to new user in oracle. [5]

A user profile in Oracle is a named set of resource limits and password management parameters that can be assigned to one or more database users. It controls and restricts the use of database resources such as CPU time, sessions, logical reads, and also enforces password policies like expiry, reu...

Open this answer on its own page →