12
13 Copyright © Oracle Corporation, 2001. All rights reserved. Controlling User Access

Controlling User Access -Data base

Embed Size (px)

Citation preview

Page 1: Controlling User Access -Data base

13Copyright © Oracle Corporation, 2001. All rights reserved.

Controlling User Access

Page 2: Controlling User Access -Data base

13-2 Copyright © Oracle Corporation, 2001. All rights reserved.

Controlling User Access

Databaseadministrator

Users

Username and passwordPrivileges

Page 3: Controlling User Access -Data base

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

Page 4: Controlling User Access -Data base

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

Page 5: Controlling User Access -Data base

13-5 Copyright © Oracle Corporation, 2001. All rights reserved.

Creating Users

The DBA creates users by using the CREATE USER statement.

CREATE USER scottIDENTIFIED BY tiger;User created.User created.

CREATE USER user IDENTIFIED BY password;

Page 6: Controlling User Access -Data base

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;

Page 7: Controlling User Access -Data base

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 viewTO scott;Grant succeeded.Grant succeeded.

Page 8: Controlling User Access -Data base

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.

Page 9: Controlling User Access -Data base

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]

Page 10: Controlling User Access -Data base

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 selectON employeesTO sue, rich;Grant succeeded.Grant succeeded.

GRANT update (department_name, location_id)ON departmentsTO scott, manager;Grant succeeded.Grant succeeded.

Page 11: Controlling User Access -Data base

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 objectFROM user

Page 12: Controlling User Access -Data base

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, insertON departmentsFROM scott;Revoke succeeded.Revoke succeeded.