KEMBAR78
Controlling User Access -Data base | PPT
13
Copyright © Oracle Corporation, 2001. All rights reserved.
Controlling User Access
13-2 Copyright © Oracle Corporation, 2001. All rights reserved.
Controlling User Access
Database
administrator
Users
Username and password
Privileges
13-3 Copyright © Oracle Corporation, 2001. All rights reserved.
Privileges
• Database security:
– System security
– Data security
• System privileges: Gaining access to the database
• Object privileges: Manipulating the content of the
database objects
13-4 Copyright © Oracle Corporation, 2001. All rights reserved.
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
13-5 Copyright © Oracle Corporation, 2001. All rights reserved.
Creating Users
The DBA creates users by using the CREATE USER
statement.
CREATE USER scott
IDENTIFIED BY tiger;
User created.User created.
CREATE USER scott
IDENTIFIED BY tiger;
User created.User created.
CREATE USER user
IDENTIFIED BY password;
13-6 Copyright © Oracle Corporation, 2001. All rights reserved.
User System Privileges
• Once a user is created, the DBA can grant specific
system privileges to a user.
GRANT privilege [, privilege...]
TO user;
GRANT privilege [, privilege...]
TO user;
13-7 Copyright © Oracle Corporation, 2001. All rights reserved.
Granting System Privileges
The DBA can grant a user specific system privileges.
GRANT create session, create table,
create sequence, create view
TO scott;
Grant succeeded.Grant succeeded.
GRANT create session, create table,
create sequence, create view
TO scott;
Grant succeeded.Grant succeeded.
13-8 Copyright © Oracle Corporation, 2001. All rights reserved.
Changing Your Password
• The DBA creates your user account and initializes
your password.
• You can change your password by using the
ALTER USER statement.
ALTER USER scott
IDENTIFIED BY lion;
User altered.User altered.
13-9 Copyright © Oracle Corporation, 2001. All rights reserved.
Object Privileges
• Object privileges vary from object to object.
• An owner has all the privileges on the object.
• An owner can give specific privileges on that
owner’s object.
GRANT object_priv [(columns)]
ON object
TO user | [PUBLIC]
GRANT object_priv [(columns)]
ON object
TO user | [PUBLIC]
13-10 Copyright © Oracle Corporation, 2001. All rights reserved.
Granting Object Privileges
• Grant query privileges on the EMPLOYEES table.
• Grant privileges to update specific columns to
users and roles.
GRANT select
ON employees
TO sue, rich;
Grant succeeded.Grant succeeded.
GRANT select
ON employees
TO sue, rich;
Grant succeeded.Grant succeeded.
GRANT update (department_name, location_id)
ON departments
TO scott, manager;
Grant succeeded.Grant succeeded.
GRANT update (department_name, location_id)
ON departments
TO scott, manager;
Grant succeeded.Grant succeeded.
13-11 Copyright © Oracle Corporation, 2001. All rights reserved.
How to Revoke Object Privileges
• You use the REVOKE statement to revoke privileges
granted to other users.
REVOKE {privilege [, privilege...]|ALL}
ON object
FROM user
REVOKE {privilege [, privilege...]|ALL}
ON object
FROM user
13-12 Copyright © Oracle Corporation, 2001. All rights reserved.
Revoking Object Privileges
As user Alice, revoke the SELECT and INSERT
privileges given to user Scott on the DEPARTMENTS
table.
REVOKE select, insert
ON departments
FROM scott;
Revoke succeeded.Revoke succeeded.
REVOKE select, insert
ON departments
FROM scott;
Revoke succeeded.Revoke succeeded.

Controlling User Access -Data base

  • 1.
    13 Copyright © OracleCorporation, 2001. All rights reserved. Controlling User Access
  • 2.
    13-2 Copyright ©Oracle Corporation, 2001. All rights reserved. Controlling User Access Database administrator Users Username and password Privileges
  • 3.
    13-3 Copyright ©Oracle Corporation, 2001. All rights reserved. Privileges • Database security: – System security – Data security • System privileges: Gaining access to the database • Object privileges: Manipulating the content of the database objects
  • 4.
    13-4 Copyright ©Oracle Corporation, 2001. All rights reserved. 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
  • 5.
    13-5 Copyright ©Oracle Corporation, 2001. All rights reserved. Creating Users The DBA creates users by using the CREATE USER statement. CREATE USER scott IDENTIFIED BY tiger; User created.User created. CREATE USER scott IDENTIFIED BY tiger; User created.User created. CREATE USER user IDENTIFIED BY password;
  • 6.
    13-6 Copyright ©Oracle Corporation, 2001. All rights reserved. User System Privileges • Once a user is created, the DBA can grant specific system privileges to a user. GRANT privilege [, privilege...] TO user; GRANT privilege [, privilege...] TO user;
  • 7.
    13-7 Copyright ©Oracle Corporation, 2001. All rights reserved. Granting System Privileges The DBA can grant a user specific system privileges. GRANT create session, create table, create sequence, create view TO scott; Grant succeeded.Grant succeeded. GRANT create session, create table, create sequence, create view TO scott; Grant succeeded.Grant succeeded.
  • 8.
    13-8 Copyright ©Oracle Corporation, 2001. All rights reserved. Changing Your Password • The DBA creates your user account and initializes your password. • You can change your password by using the ALTER USER statement. ALTER USER scott IDENTIFIED BY lion; User altered.User altered.
  • 9.
    13-9 Copyright ©Oracle Corporation, 2001. All rights reserved. Object Privileges • Object privileges vary from object to object. • An owner has all the privileges on the object. • An owner can give specific privileges on that owner’s object. GRANT object_priv [(columns)] ON object TO user | [PUBLIC] GRANT object_priv [(columns)] ON object TO user | [PUBLIC]
  • 10.
    13-10 Copyright ©Oracle Corporation, 2001. All rights reserved. Granting Object Privileges • Grant query privileges on the EMPLOYEES table. • Grant privileges to update specific columns to users and roles. GRANT select ON employees TO sue, rich; Grant succeeded.Grant succeeded. GRANT select ON employees TO sue, rich; Grant succeeded.Grant succeeded. GRANT update (department_name, location_id) ON departments TO scott, manager; Grant succeeded.Grant succeeded. GRANT update (department_name, location_id) ON departments TO scott, manager; Grant succeeded.Grant succeeded.
  • 11.
    13-11 Copyright ©Oracle Corporation, 2001. All rights reserved. How to Revoke Object Privileges • You use the REVOKE statement to revoke privileges granted to other users. REVOKE {privilege [, privilege...]|ALL} ON object FROM user REVOKE {privilege [, privilege...]|ALL} ON object FROM user
  • 12.
    13-12 Copyright ©Oracle Corporation, 2001. All rights reserved. Revoking Object Privileges As user Alice, revoke the SELECT and INSERT privileges given to user Scott on the DEPARTMENTS table. REVOKE select, insert ON departments FROM scott; Revoke succeeded.Revoke succeeded. REVOKE select, insert ON departments FROM scott; Revoke succeeded.Revoke succeeded.

Editor's Notes

  • #2 Schedule:TimingTopic 20 minutesLecture 20 minutesPractice 40 minutesTotal
  • #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 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.
  • #4 Privileges Privileges are the right to execute particular SQL statements. The database administrator (DBA) 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. Schemas 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 Oracle9i Application Developer’s Guide - Fundamentals, “Establishing a Security Policy” section, and Oracle9i Concepts, “Database Security” topic.
  • #5 System Privileges More than 100 distinct 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 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: useris the name of the user to be created passwordspecifies that the user must log in with this password For more information, see Oracle9i SQL Reference, “GRANT” and “CREATE USER.” Instructor Note For information on DROP USER, refer to Oracle9i SQL Reference, “DROP USER.”
  • #7 Typical User Privileges Now that the DBA has created a user, the DBA can assign privileges to that user. In the syntax: privilegeis the system privilege to be granted user|role|PUBLICis the name of the user, the name of the role, or PUBLIC designates that every user is granted the privilege Note: Current system privileges can be found in the dictionary view SESSION_PRIVS. Instructor 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 sessions, tables, sequences, and views. Instructor Note A user needs to have the required space quota to create tables.
  • #9 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; In the syntax: useris the name of the user passwordspecifies 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 Oracle9i SQL Reference, “ALTER USER.”
  • #10 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 WITH GRANT OPTION, then 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_privis an object privilege to be granted ALLspecifies all object privileges columnsspecifies the column from a table or view on which privileges are granted ON objectis the object on which the privileges are granted TOidentifies to whom the privilege is granted PUBLICgrants object privileges to all users WITH GRANT OPTION allows the grantee to grant the object privileges to other users and roles
  • #11 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 EMPLOYEES table. The second example grants UPDATE privileges on specific columns in the DEPARTMENTS table to Scott and to the manager role. If Sue or Rich now want to SELECT data from the employees table, the syntax they must use is: SELECT * FROM scott.employees; Alternatively, they can create a synonym for the table and SELECT from the synonym: CREATE SYNONYM emp FOR scott.employees; SELECT * FROM emp; Note: DBAs generally allocate system privileges; any user who owns an object can grant object privileges. Instructor Note Please read the Instructor Note at the end of this lesson.
  • #12 Revoking Object Privileges You can 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 you name and from any other users to whom those privileges were granted through the WITH GRANT OPTION clause. In the syntax: CASCADEis required to remove any referential integrity constraints made to the CONSTRAINTSobject by means of the REFERENCES privilege For more information, see Oracle9i SQL Reference, “REVOKE.”
  • #13 Revoking Object Privileges (continued) The example on the slide revokes SELECT and INSERT privileges given to user Scott on the DEPARTMENTS table. Note: If a user is granted a privilege with the WITH GRANT OPTION clause, that user can also grant the privilege with the WITH GRANT OPTION clause, 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 revoking cascades to all privileges granted. For example, if user A grants SELECT privilege on a table to user B including the WITH GRANT OPTION clause, user B can grant to user C the SELECT privilege with the WITH GRANT OPTION clause as well, and user C can then grant to user D the SELECT privilege. If user A revokes privilege from user B, then the privileges granted to users C and D are also revoked. Instructor Note Revoking system privileges is not within the scope of this lesson. For information on this topic refer to: Oracle9i SQL Reference, “REVOKE system_privileges_and_roles. ”