SlideShare a Scribd company logo
1 of 20
Controlling User Access
Objectives ,[object Object],[object Object],[object Object],[object Object]
Controlling User Access Database administrator Users Username and password privileges
Privileges ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
System Privileges ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creating Users ,[object Object],SQL> CREATE USER  scott 2  IDENTIFIED BY tiger; User created. CREATE USER    user     IDENTIFIED BY  password ;
User System Privileges GRANT  privilege  [,  privilege ...] TO  user  [,  user ...]; ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Granting System Privileges ,[object Object],SQL> GRANT  create table, create sequence, create view 2  TO  scott; Grant succeeded.
What Is a Role? Allocating privileges without a role Allocating privileges with a role Privileges Users Manager
Creating and Granting Privileges to a Role SQL> CREATE ROLE manager; Role created.   SQL> GRANT create table, create view    2   to manager;  Grant succeeded.   SQL> GRANT manager to BLAKE, CLARK;  Grant succeeded.
Changing Your Password ,[object Object],[object Object],SQL> ALTER USER scott    2   IDENTIFIED BY lion; User altered.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Object Privileges
Object Privileges ,[object Object],[object Object],[object Object],GRANT object_priv  [( columns )] ON object TO { user | role |PUBLIC} [WITH GRANT OPTION];
Granting Object Privileges ,[object Object],SQL> GRANT select 2  ON emp 3  TO sue, rich; Grant succeeded. SQL> GRANT update (dname, loc) 2  ON dept 3  TO scott, manager; Grant succeeded. ,[object Object]
Using WITH GRANT OPTION and PUBLIC Keywords ,[object Object],SQL> GRANT select, insert 2  ON dept 3  TO scott 4  WITH GRANT OPTION; Grant succeeded. SQL> GRANT select 2  ON alice.dept 3  TO PUBLIC; Grant succeeded. ,[object Object]
Confirming Privileges Granted Data Dictionary Table Description ROLE_SYS_PRIVS System privileges granted to roles ROLE_TAB_PRIVS Table privileges granted to roles USER_ROLE_PRIVS Roles accessible by the user USER_TAB_PRIVS_MADE Object privileges granted on the  user’s objects USER_TAB_PRIVS_RECD Object privileges granted to the  user USER_COL_PRIVS_MADE Object privileges granted on the  columns of the user’s objects USER_COL_PRIVS_RECD Object privileges granted to the  user on specific columns
How to Revoke Object Privileges ,[object Object],[object Object],REVOKE {privilege [, privilege...]|ALL} ON   object FROM  {user[, user...]|role|PUBLIC} [CASCADE CONSTRAINTS];
Revoking Object Privileges ,[object Object],SQL> REVOKE select, insert 2  ON dept 3  FROM scott; Revoke succeeded.
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Practice Overview ,[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

What's hot (19)

Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Sequences and indexes
Sequences and indexesSequences and indexes
Sequences and indexes
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 
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
 
Mysql Ppt
Mysql PptMysql Ppt
Mysql Ppt
 
Oracle training in hyderabad
Oracle training in hyderabadOracle training in hyderabad
Oracle training in hyderabad
 
Sql views
Sql viewsSql views
Sql views
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)
 
Controlling User Access -Data base
Controlling User Access -Data baseControlling User Access -Data base
Controlling User Access -Data base
 
Commands of DML in SQL
Commands of DML in SQLCommands of DML in SQL
Commands of DML in SQL
 
Cursors, triggers, procedures
Cursors, triggers, proceduresCursors, triggers, procedures
Cursors, triggers, procedures
 
Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Best sql plsql material
Best sql plsql materialBest sql plsql material
Best sql plsql material
 
Avinash database
Avinash databaseAvinash database
Avinash database
 
database-querry-student-note
database-querry-student-notedatabase-querry-student-note
database-querry-student-note
 

Viewers also liked (20)

Unit 06 dbms
Unit 06 dbmsUnit 06 dbms
Unit 06 dbms
 
Unit3 C
Unit3 C Unit3 C
Unit3 C
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
Les01
Les01Les01
Les01
 
Les02
Les02Les02
Les02
 
Les06
Les06Les06
Les06
 
Les12
Les12Les12
Les12
 
Unit 1 watertech1 merged
Unit 1 watertech1 mergedUnit 1 watertech1 merged
Unit 1 watertech1 merged
 
Les09
Les09Les09
Les09
 
Les10
Les10Les10
Les10
 
Les11
Les11Les11
Les11
 
Les03
Les03Les03
Les03
 
Unit 03 dbms
Unit 03 dbmsUnit 03 dbms
Unit 03 dbms
 
Unit 01 dbms
Unit 01 dbmsUnit 01 dbms
Unit 01 dbms
 
Unit 07 dbms
Unit 07 dbmsUnit 07 dbms
Unit 07 dbms
 
Unit 5 Java
Unit 5 JavaUnit 5 Java
Unit 5 Java
 
Unit 04 dbms
Unit 04 dbmsUnit 04 dbms
Unit 04 dbms
 
Unit 08 dbms
Unit 08 dbmsUnit 08 dbms
Unit 08 dbms
 
Unit 05 dbms
Unit 05 dbmsUnit 05 dbms
Unit 05 dbms
 

Similar to Les14

Les14[1]Controlling User Access
Les14[1]Controlling User AccessLes14[1]Controlling User Access
Les14[1]Controlling User Accesssiavosh kaviani
 
e computer notes - Controlling user access
e computer notes - Controlling user accesse computer notes - Controlling user access
e computer notes - Controlling user accessecomputernotes
 
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
 
Security in Relational model
Security in Relational modelSecurity in Relational model
Security in Relational modelSlideshare
 
Sql grant, revoke, privileges and roles
Sql grant, revoke, privileges and rolesSql grant, revoke, privileges and roles
Sql grant, revoke, privileges and rolesVivek Singh
 
Database administration
Database administrationDatabase administration
Database administrationabhi_love
 
User, roles and privileges
User, roles and privilegesUser, roles and privileges
User, roles and privilegesYogiji Creations
 
Sql ch 15 - sql security
Sql ch 15 - sql securitySql ch 15 - sql security
Sql ch 15 - sql securityMukesh Tekwani
 
03_DP_300T00A_Secure_Environment.pptx
03_DP_300T00A_Secure_Environment.pptx03_DP_300T00A_Secure_Environment.pptx
03_DP_300T00A_Secure_Environment.pptxKareemBullard1
 
Oracle Database Security For Developers
Oracle Database Security For DevelopersOracle Database Security For Developers
Oracle Database Security For DevelopersSzymon Skorupinski
 
Write the query for creating the users exp 11
Write the query for creating the users exp 11Write the query for creating the users exp 11
Write the query for creating the users exp 11vishal choudhary
 
Database administration commands
Database administration commands Database administration commands
Database administration commands Varsha Ajith
 

Similar to Les14 (20)

Les13
Les13Les13
Les13
 
Les01
Les01Les01
Les01
 
Les14[1]Controlling User Access
Les14[1]Controlling User AccessLes14[1]Controlling User Access
Les14[1]Controlling User Access
 
e computer notes - Controlling user access
e computer notes - Controlling user accesse computer notes - Controlling user access
e computer notes - Controlling user access
 
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
 
Security in Relational model
Security in Relational modelSecurity in Relational model
Security in Relational model
 
Sql grant, revoke, privileges and roles
Sql grant, revoke, privileges and rolesSql grant, revoke, privileges and roles
Sql grant, revoke, privileges and roles
 
Database administration
Database administrationDatabase administration
Database administration
 
User, roles and privileges
User, roles and privilegesUser, roles and privileges
User, roles and privileges
 
Less07 Users
Less07 UsersLess07 Users
Less07 Users
 
Db pre
Db preDb pre
Db pre
 
Sql ch 15 - sql security
Sql ch 15 - sql securitySql ch 15 - sql security
Sql ch 15 - sql security
 
03_DP_300T00A_Secure_Environment.pptx
03_DP_300T00A_Secure_Environment.pptx03_DP_300T00A_Secure_Environment.pptx
03_DP_300T00A_Secure_Environment.pptx
 
Trigger in DBMS
Trigger in DBMSTrigger in DBMS
Trigger in DBMS
 
Oracle Database Security For Developers
Oracle Database Security For DevelopersOracle Database Security For Developers
Oracle Database Security For Developers
 
Write the query for creating the users exp 11
Write the query for creating the users exp 11Write the query for creating the users exp 11
Write the query for creating the users exp 11
 
Database administration commands
Database administration commands Database administration commands
Database administration commands
 
Dbms
DbmsDbms
Dbms
 
Mysql
MysqlMysql
Mysql
 

More from arnold 7490 (17)

Les07
Les07Les07
Les07
 
Les05
Les05Les05
Les05
 
Les04
Les04Les04
Les04
 
Unit 4 Java
Unit 4 JavaUnit 4 Java
Unit 4 Java
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
 
Unit 2 Java
Unit 2 JavaUnit 2 Java
Unit 2 Java
 
Unit 1 Java
Unit 1 JavaUnit 1 Java
Unit 1 Java
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
 
Unit5 C
Unit5 C Unit5 C
Unit5 C
 
Unit4 C
Unit4 C Unit4 C
Unit4 C
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
 
Unit1 C
Unit1 CUnit1 C
Unit1 C
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
 
Unit1 C
Unit1 CUnit1 C
Unit1 C
 
Unit8 C
Unit8 CUnit8 C
Unit8 C
 

Recently uploaded

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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
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
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
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
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
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
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

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
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
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
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
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
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
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
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

Les14

  • 2.
  • 3. Controlling User Access Database administrator Users Username and password privileges
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. What Is a Role? Allocating privileges without a role Allocating privileges with a role Privileges Users Manager
  • 10. Creating and Granting Privileges to a Role SQL> CREATE ROLE manager; Role created. SQL> GRANT create table, create view 2 to manager; Grant succeeded. SQL> GRANT manager to BLAKE, CLARK; Grant succeeded.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Confirming Privileges Granted Data Dictionary Table Description ROLE_SYS_PRIVS System privileges granted to roles ROLE_TAB_PRIVS Table privileges granted to roles USER_ROLE_PRIVS Roles accessible by the user USER_TAB_PRIVS_MADE Object privileges granted on the user’s objects USER_TAB_PRIVS_RECD Object privileges granted to the user USER_COL_PRIVS_MADE Object privileges granted on the columns of the user’s objects USER_COL_PRIVS_RECD Object privileges granted to the user on specific columns
  • 17.
  • 18.
  • 19.
  • 20.

Editor's Notes

  1. Schedule: Timing Topic 15 minutes Lecture 20 minutes Practice 35 minutes Total
  2. Lesson Aim In this lesson, you will learn how to control database access to specific objects and add new users with different levels of access privileges.
  3. Controlling User Access 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 username and password, disk space allocated to users, and system operations allowed by the user. Database security covers access and use of the database objects and the actions that those users can have on the objects.
  4. Privileges Privileges are the right to execute particular SQL statements. The database administrator is a high-level user with the ability to grant users access to the database and its objects. The users require system privileges to gain access to the database and object privileges to manipulate the content of the objects in the database. Users can also be given the privilege to grant additional privileges to other users or to roles , which are named groups of related privileges. Schema A schema is a collection of objects, such as tables, views, and sequences. The schema is owned by a database user and has the same name as that user. For more information, see Oracle Server Application Developer’s Guide, Release 8, “Establishing a Security Policy” section, and Oracle Server Concepts Manual , Release 8, “Database Security” topic.
  5. System Privileges More than 80 system privileges are available for users and roles. System privileges typically are provided by the database administrator. Typical DBA Privileges
  6. Creating a User The DBA creates the user by executing the CREATE USER statement. The user does not have any privileges at this point. The DBA can then grant a number of privileges to that user. These privileges determine what the user can do at the database level. The slide gives the abridged syntax for creating a user. In the syntax: user is the name of the user to be created password specifies that the user must log in with this password For more information, see Oracle Server SQL Reference, Release 8, “GRANT” (System Privileges and Roles) and “CREATE USER.”
  7. Typical User Privileges Now that the DBA has created a user, the DBA can assign privileges to that user. In the syntax: privilege is the system privilege to be granted user is the name of the user Class Management Note The syntax displayed for the GRANT command is not the full syntax for the statement.
  8. Granting System Privileges The DBA uses the GRANT statement to allocate system privileges to the user. Once the user has been granted the privileges, the user can immediately use those privileges. In the example on the slide, user Scott has been assigned the privileges to create tables, sequences, and views. Class Management Note A user needs to have the required space quota to create tables.
  9. What Is a Role? A role is a named group of related privileges that can be granted to the user. This method makes granting and revoking privileges easier to perform and maintain. A user can have access to several roles, and several users can be assigned the same role. Roles typically are 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 users to the role. Syntax CREATE ROLE role ; where: role is the name of the role to be created Now that the role is created, the DBA can use the GRANT statement to assign users to the role as well as assign privileges to the role. Class Management Note Discuss the four following points about roles: Are named groups of related privileges Can be granted to users Simplify the process of granting and revoking privileges Are created by a DBA
  10. Creating a Role The example on the slide creates a role manager and then allows the managers to create tables and views. It then grants Blake and Clark the role of managers. Now Blake and Clark can create tables and views.
  11. Changing Your Password The DBA creates an account and initializes a password for every user. You can change your password by using the ALTER USER statement. Syntax ALTER USER user IDENTIFIED BY password; where: user is the name of the user password specifies the new password Although this statement can be used to change your password, there are many other options. You must have the ALTER USER privilege to change any other option. For more information, see Oracle Server SQL Reference, Release 8, “ALTER USER.”
  12. Object Privileges An object privilege is a privilege or right to perform a particular action on a specific table, view, sequence, or procedure. Each object has a particular set of grantable privileges. The table on the slide lists the privileges for various objects. Note that the only privileges that apply to a sequence are SELECT and ALTER. UPDATE, REFERENCES, and INSERT can be restricted by specifying a subset of updatable columns. A SELECT can be restricted by creating a view with a subset of columns and granting SELECT privilege on the view. A grant on a synonym is converted to a grant on the base table referenced by the synonym.
  13. Granting Object Privileges Different object privileges are available for different types of schema objects. A user automatically has all object privileges for schema objects contained in the user’s schema. A user can grant any object privilege on any schema object that the user owns to any other user or role. If the grant includes the GRANT OPTION, the grantee can further grant the object privilege to other users; otherwise, the grantee can use the privilege but cannot grant it to other users. In the syntax: object_priv is an object privilege to be granted ALL specifies all object privileges. columns specifies the column from a table or view on which privileges are granted ON object is the object on which the privileges are granted TO identifies to whom the privilege is granted PUBLIC grants object privileges to all users WITH GRANT OPTION allows the grantee to grant the object privileges to other users and roles
  14. Guidelines To grant privileges on an object, the object must be in your own schema or you must have been granted the object privileges WITH GRANT OPTION. An object owner can grant any object privilege on the object to any other user or role of the database. The owner of an object automatically acquires all object privileges on that object. The first example on the slide grants users Sue and Rich the privilege to query your EMP table. The second example g rants UPDATE privileges on specific columns in the DEPT table to Scott and to the manager role. Note: DBAs generally allocate system privileges; any user who owns an object can grant object privileges.
  15. WITH GRANT OPTION Keyword A privilege that is granted WITH GRANT OPTION can be passed on to other users and roles by the grantee. Object privileges granted WITH GRANT OPTION are revoked when the grantor’s privilege is revoked. The example on the slide gives user Scott access to your DEPT table with the privileges to query the table and add rows to the table. The example also allows Scott to give others these privileges. PUBLIC Keyword An owner of a table can grant access to all users by using the PUBLIC keyword. The second example allows all users on the system to query data from Alice’s DEPT table. Class Management Note If a statement does not use the full name of an object, the Oracle Server implicitly prefixes the object name with the current user’s name (or schema). If user Scott queries the DEPT table, the system will SELECT from table SCOTT.DEPT. If a statement does not use the full name of an object, and the current user does not own an object of that name, the system will prefix the object name with PUBLIC. For example, if user Scott queries the USER_OBJECTS table, and Scott does not own such a table, the system will SELECT from the data dictionary view by way of the PUBLIC.USER_OBJECTS public synonym.
  16. Confirming Privileges Granted If you attempt to perform an unauthorized operation—for example, deleting a row from a table for which you do not have the DELETE privilege—the Oracle Server will not permit the operation to take place. If you receive the Oracle Server error message “table or view does not exist,” you have done either of the following: Named a table or view that does not exist Attempted to perform an operation on a table or view for which you do not have the appropriate privilege You can access the data dictionary to view the privileges that you have. The table on the slide describes various data dictionary tables.
  17. Revoking Object Privileges Remove privileges granted to other users by using the REVOKE statement. When you use the REVOKE statement, the privileges that you specify are revoked from the users that you name and from any other users to whom those privileges may have been granted through the WITH GRANT OPTION clause. In the syntax: CASCADE is required to remove any referential integrity constraints made to the CONSTRAINTS object by means of the REFERENCES privilege For more information, see Oracle Server SQL Reference, Release 8, “REVOKE.”
  18. Revoking Object Privileges (continued) The example on the slide revokes SELECT and INSERT privileges given to user Scott on the DEPT table. Note: If a user is granted a privilege WITH GRANT OPTION, that user can also grant the privilege WITH GRANT OPTION, so that a long chain of grantees is possible, but no circular grants are permitted. If the owner revokes a privilege from a user who granted the privilege to other users, the REVOKE cascades to all privileges granted. For example, if user A grants SELECT privilege on a table to user B including the WITH GRANT OPTION, user B can grant to user C the SELECT privilege WITH GRANT OPTION, and user C can then grant to user D the SELECT privilege. If user A the revokes then privilege from user B, then the privileges granted to users C and D are also revoked.
  19. Summary DBAs establish initial database security for users by assigning privileges to the users. The DBA creates users who must have a password. The DBA is also responsible for establishing the initial system privileges for a user. Once the user has created an object, the user can pass along any of the available object privileges to other users or to all users by using the GRANT statement. A DBA can create roles by using the CREATE ROLE statement to pass along a collection of system or object privileges to multiple users. Roles make granting and revoking privileges easier to maintain. Users can change their password by using the ALTER USER statement. You can remove privileges from users by using the REVOKE statement. Data dictionary views allow users to view the privileges granted to them and those that are granted on their objects.
  20. Practice Overview Team up with other students for this exercise of controlling access to database objects.