+ All Categories
Home > Education > Create user database management security

Create user database management security

Date post: 25-May-2015
Category:
Upload: hct
View: 121 times
Download: 0 times
Share this document with a friend
Description:
database management security, security of database, database security, oracle 11g, user, profile, quota, tablespace, temporary tablespace, role,dba_users, dba_Ts_quotas
Popular Tags:
33
Chapter 3- Database users 1 Chapter 3 - Dr. Girija Narasimhan
Transcript
Page 1: Create user  database management security

Chapter 3- Database users

1 Chapter 3 - Dr. Girija Narasimhan

Page 2: Create user  database management security

2 Chapter 3 - Dr. Girija Narasimhan

Creating a New User Account (P 2-2)

Create a database user with the CREATE USER system privilege. A database administrator or security administrator is usually the only user who has the CREATE USER system privilege.

CREATE USER jward

IDENTIFIED BY jw

DEFAULT TABLESPACE data_ts

QUOTA 100M ON test_ts

QUOTA 500K ON data_ts

TEMPORARY TABLESPACE temp_ts

PROFILE clerk;

GRANT CREATE SESSION TO jward;

A newly created user cannot connect to the database until you grant the user the CREATE SESSION system privileges.

Page 3: Create user  database management security

3 Chapter 3 - Dr. Girija Narasimhan

Specifying a User Name (p 2-2)

Within each database, a user name must be unique with respect to other user names and roles. A user and role cannot have the same name.

User Ahmed is stored in the database in upper-case letters.

Page 4: Create user  database management security

4 Chapter 3 - Dr. Girija Narasimhan

if you enclose the user name in double quotation marks, then the name is

stored using the case sensitivity that you used for the name. (p. 2-3)

Drop the user that you had created using double

quotation marks, then you must enclose the user

name in double quotation marks

Page 5: Create user  database management security

5 Chapter 3 - Dr. Girija Narasimhan

Assigning a Default Tablespace for the User (p. 2-4)

Each user should have a default tablespace.

When a schema object is created in the user’s schema and the DDL

statement does not specify a tablespace to contain the object, Oracle

Database stores the object in the default user’s tablespace.

By default setting

Purpose of default table space

default tablespaces of all users is the SYSTEM tablespace

In general, do not store user data in the SYSTEM tablespace, then user should

specifically assign the user a default tablespace, such as the USERS tablespace

(refer slide no. 6)

How user create default tablespace

use the CREATE TABLESPACE SQL statement to create a default

permanent tablespace other than SYSTEM at the time of database creation

(refer slide no.7)

Page 6: Create user  database management security

Chapter 3 - Dr. Girija Narasimhan 6

Create New User Without Determine which Tablespace:

SQL> create user amar identified by amar;

Check TableSpace for AMAR User:

SQL> select default_tablespace from dba_users where username= 'AMAR';

DEFAULT_TABLESPACE

------------------------------

USERS

(OR)

define Tablespace When Creating User

SQL > create user amar identified by amar default tablespace USER

USERS tablespace

Page 7: Create user  database management security

Chapter 3 - Dr. Girija Narasimhan 7

SQL> CREATE TABLESPACE amar_ts

DATAFILE 'c:\temp\amar1.dbf' SIZE 1M EXTENT MANAGEMENT LOCAL

SEGMENT SPACE MANAGEMENT AUTO;

Tablespace created.

SQL> alter database default tablespace AMAR_TS;

Database altered.

SQL> select default_tablespace from dba_users where username='AMAR';

DEFAULT_TABLESPACE

------------------------------

AMAR_TS

CREATE TABLESPACE using default tablespace

Page 8: Create user  database management security

8 Chapter 3 - Dr. Girija Narasimhan

This default permanent tablespace is not used by system users, that

is, SYS, SYSTEM, and OUTLN,

User created default permanent tablespace

Tablespace designated as the default permanent tablespace cannot be dropped.

Features of user created default permanent tablespace

use the ALTER TABLESPACE SQL statement to alter the default

permanent tablespace to another tablespace

set a user default tablespace during user creation, and change it later

with the ALTER USER statement. (refer slide 9)

Alternative method to create user default tablespace

Changing the user default tablespace affects only objects created after the

setting is changed.

Page 9: Create user  database management security

SQL> select default_tablespace from dba_users where username='AMAR';

DEFAULT_TABLESPACE

------------------------------

AMAR_TS

SQL> alter user amar default tablespace USERS;

User altered.

SQL> select default_tablespace from dba_users where username='AMAR';

DEFAULT_TABLESPACE

------------------------------

USERS

ALTER USER statement Change the default tablespace

9 Chapter 3 - Dr. Girija Narasimhan

Page 10: Create user  database management security

10 Chapter 3 - Dr. Girija Narasimhan

Assign each user a tablespace quota for any tablespace

Assigning a Tablespace Quota for the User (p 2-5)

By default, a user has no quota on any tablespace in the database

If the user has the privilege to create a schema object, then

you must assign a quota to allow the user to create objects

Purpose of Quota

CREATE USER ahmed

IDENTIFIED BY ahmed

DEFAULT TABLESPACE users

QUOTA 100M ON test_ts

QUOTA 500K ON data_ts

TEMPORARY TABLESPACE temp_ts

PROFILE clerk;

GRANT CREATE SESSION TO ahmed;

Oracle database limits the

amount of space that can

be allocated for storage of a

user’s objects within the

specified tablespace to the

amount of the quota.

Users with privileges to

create certain types of

objects can create

those objects in the

specified tablespace

Page 11: Create user  database management security

11 Chapter 3 - Dr. Girija Narasimhan

Assigning a Temporary Tablespace for the User (P. 2-6)

You should assign each user a temporary tablespace.

When a user executes a SQL statement that requires a temporary segment,

Oracle Database stores the segment in the temporary tablespace of the

user.(slide 13)

Why needed? Or purpose

These temporary segments are created by the system when

performing sort or join operations

The owner is sys – how?

SYS, which has resource privileges in all tablespaces.

Who and when?

Page 12: Create user  database management security

12 Chapter 3 - Dr. Girija Narasimhan

Temporary Tablespace

By default SYSTEM table space

If <user explicitly don’t create> then

<Else> Method 1

Method 2

By an ALTER DATABASE

Statement at a later time

(slide 14)

Oracle database assigns the

user the default temporary

tablespace that was specified

at database creation

Page 13: Create user  database management security

13 Chapter 3 - Dr. Girija Narasimhan

SQL> select TEMPORARY_TABLESPACE from DBA_USERS where USERNAME='AMAR';

TEMPORARY_TABLESPACE

------------------------------

TEMP

SQL> CREATE TEMPORARY TABLESPACE TEMP_TS TEMPFILE 'C:\TEMP\AMAR_tEMP.DBF'

SIZE 20M REUSE

EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;

Tablespace created.

SQL> alter user amar temporary tablespace TEMP_TS;

User altered.

SQL> select TEMPORARY_TABLESPACE from DBA_USERS where

USERNAME='AMAR';

TEMPORARY_TABLESPACE

------------------------------

TEMP_TS

Page 14: Create user  database management security

SQL> alter database default temporary tablespace TEMP_TS;

Database altered.

SQL> select TEMPORARY_TABLESPACE from DBA_USERS where

USERNAME='AMAR';

TEMPORARY_TABLESPACE

------------------------------

TEMP_TS

SQL> select TEMPORARY_TABLESPACE from DBA_USERS where

USERNAME='AMAR';

TEMPORARY_TABLESPACE

------------------------------

TEMP

ALTER DATABASE

Chapter 3 - Dr. Girija Narasimhan 14

Page 15: Create user  database management security

15 Chapter 3 - Dr. Girija Narasimhan

Specifying a Profile for the User (p 2-7)

profile is a set of limits on database resources and password

access to the database.

What is profile?

specify a profile when you create a user.

Do not specify a profile, then Oracle Database assigns the user a default profile

CREATE USER ahmed

IDENTIFIED BY ahmed

DEFAULT TABLESPACE USERS

QUOTA 500K ON USERS

TEMPORARY TABLESPACE temp_ts

PROFILE clerk

create profile clerk limit

sessions_per_user 1

idle_time 30

connect_time 600;

Profile created.

Page 16: Create user  database management security

Chapter 3 - Dr. Girija Narasimhan 16

Dropping Profiles (P. 2-14)

To drop a profile, you must have the DROP PROFILE system privilege.

You can drop a profile (other than the default profile) using the SQL

statement DROP PROFILE.

To successfully drop a profile currently assigned to a user , use the

CASCADE option. (slide 17)

The following statement drops the profile clerk, even though it is assigned to

a user:

DROP PROFILE clerk CASCADE;

Any user currently assigned to a profile that is dropped is automatically

assigned to the DEFAULT profile. (slide 18)

The DEFAULT profile cannot be dropped. When a profile is

dropped, the drop does not affect currently active sessions. (slide 19)

Only sessions created after a profile is dropped use the modified profile

assignments.

Page 17: Create user  database management security

17 chapter 3 -Dr. Girija Narasimhan

SQL> create profile clerk limit

2 sessions_per_user 1

3 idle_time 30

4 connect_time 600;

Profile created.

SQL> select username,profile from dba_users where

username='AMAR';

USERNAME PROFILE

------------------------------ -------------------------

AMAR DEFAULT

SQL> ALTER USER AMAR PROFILE CLERK;

User altered.

SQL> DROP PROFILE CLERK;

DROP PROFILE CLERK

*

ERROR at line 1:

ORA-02382: profile CLERK has users assigned, cannot

drop without CASCADE

SQL> DROP PROFILE CLERK CASCADE;

Profile dropped.

currently

assigned to a

user, use the

CASCADE

option.

Oracle Database assigns

the user a default profile

Chapter 3 - Dr. Girija Narasimhan 17

Page 18: Create user  database management security

SQL> create profile clerk limit

sessions_per_user 1

idle_time 30

connect_time 600;

Profile created.

SQL> ALTER USER AMAR PROFILE CLERK;

User altered.

SQL> select username,profile from dba_users where username='AMAR';

USERNAME PROFILE

------------------------------ ------------------------------

AMAR CLERK

SQL> DROP PROFILE CLERK CASCADE;

Profile dropped.

SQL> select username,profile from dba_users where username='AMAR';

USERNAME PROFILE

------------------------------ ------------------------------

AMAR DEFAULT1818

Any user currently assigned to a profile that is dropped is

automatically assigned to the DEFAULT profile.

Chapter 3 - Dr. Girija Narasimhan 18

Page 19: Create user  database management security

SQL> DROP PROFILE default;

DROP PROFILE default

*

ERROR at line 1:

ORA-00931: missing identifier

SQL> DROP PROFILE DEFAULT CASCADE;

DROP PROFILE DEFAULT CASCADE

*

ERROR at line 1:

ORA-00931: missing identifier

The DEFAULT profile cannot be dropped

SQL> CREATE ROLE CLERK;

Role created.

SQL> CREATE USER AMAR IDENTIFIED BY CL

PROFILE CLERK;

User created.

SQL> GRANT CLERK TO AMAR;

Grant succeeded.

No need role and

profile has unique

name, i.e same name

allowed.

only role and user name

not same name (it

should be unique)

Chapter 3 - Dr. Girija Narasimhan 19

Page 20: Create user  database management security

Chapter 3 - Dr. Girija Narasimhan

Using the ALTER USER Statement to Alter a User Account (P 2-8)

You can alter user security settings with the ALTER USER SQL statement.

Changing user security settings affects the future user sessions, not current

sessions.

ALTER USER avyrros

IDENTIFIED EXTERNALLY

DEFAULT TABLESPACE data_ts

TEMPORARY TABLESPACE temp_ts

QUOTA 100M ON data_ts

QUOTA 0 ON test_ts

PROFILE clerk;

The quota on the

test_ts is revoked for

the user avyrros.

Authentication is changed to use the

operating system (from database)

account of the user avyrros. For

database need password

Page 21: Create user  database management security

21 Chapter 3 - Dr. Girija Narasimhan

SQL> alter user ahmed identified by ah;

User altered.

Changing Non-SYS User Passwords (p. 2-8)

Most users can change their own passwords with the PASSWORD

statement, as follows:

No special privileges (other than those to connect to the database and

create a session) are required for a user to change his or her own

password.

Deleting User Accounts (p 2-14)

When you drop a user account, Oracle Database removes the

user account and associated schema from the data dictionary.

It also immediately drops all schema objects contained in the user

schema

DROP USER AMAR CASCADE;

Page 22: Create user  database management security

22 Chapter 3 - Dr. Girija Narasimhan

To find all users and their associated information as defined in the

database, query the DBA_USERS view

SQL> SET LINESIZE 300;

SQL> SELECT USERNAME, PROFILE, ACCOUNT_STATUS, AUTHENTICATION_TYPE FROM

DBA_USERS WHERE USERNAME='AMAR';

USERNAME PROFILE ACCOUNT_STATUS AUTHENTI

------------------------------ ------------------------------

AMAR DEFAULT OPEN PASSWORD

Listing All Users and Associated Information (P 2-16)

Page 23: Create user  database management security

23 Chapter 3 - Dr. Girija Narasimhan

SQL> SELECT * FROM DBA_TS_QUOTAS;

Listing All Tablespace Quotas (P 2-17)

Use the DBA_TS_QUOTAS view to list all tablespace quotas

specifically assigned to each user.

When specific quotas are assigned, the exact number is indicated

in the MAX_BYTES column.

This number is always a multiple of the database block size, so if

you specify a tablespace quota that is not a multiple of the

database block size, then it is rounded up accordingly. Unlimited

quotas are indicated by -1.

Page 24: Create user  database management security

The DBA_PROFILE view lists all profiles in the database and

associated settings for each limit in each profile.

Listing All Profiles and Assigned

Limits (P 2-17)

SQL> SET LINESIZE 300;

SQL> SELECT * FROM DBA_PROFILES WHERE PROFILE='CLERK';

Chapter 3 - Dr. Girija Narasimhan 24

Page 25: Create user  database management security

SQL> set linesize 300;

SQL> select DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE,username from

dba_users;

DEFAULT_TABLESPACE TEMPORARY_TABLESPACE USERNAME

------------------------------ ------------------------------

SYSTEM TEMP_TS SYSTEM

SYSTEM TEMP_TS SYS

SYSTEM TEMP_TS MGMT_VIEW

SYSAUX TEMP_TS DBSNMP

SYSAUX TEMP_TS SYSMAN

AMAR_TS TEMP_TS JINAN

AMAR_TS TEMP_TS REEM

AMAR_TS TEMP_TS SAFA

AMAR_TS TEMP_TS AMAR

AMAR_TS TEMP_TS HR

AMAR_TS TEMP_TS TALIB

SQL> alter database default tablespace USERS;

Database altered.

SQL> ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP;

Database altered.

DROP and ALTER TABLESPACE

Page 26: Create user  database management security

SQL> set linesize 300;

SQL> select DEFAULT_TABLESPACE,TEMPORARY_TABLESPACE,username from

dba_users;

DEFAULT_TABLESPACE TEMPORARY_TABLESPACE USERNAME

------------------------------ ---------------------------SYSTEM

TEMP SYSTEM

SYSTEM TEMP SYS

SYSTEM TEMP MGMT_VIEW

SYSAUX TEMP DBSNMP

SYSAUX TEMP SYSMAN

USERS TEMP JINAN

USERS TEMP REEM

USERS TEMP SAFA

USERS TEMP AMAR

USERS TEMP HR

USERS TEMP TALIB

SQL> DROP TABLESPACE AMAR_TS INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

SQL> DROP TABLESPACE TEMP_TS INCLUDING CONTENTS AND DATAFILES;

Tablespace dropped.

Page 27: Create user  database management security

27 Chapter 3 - Dr. Girija Narasimhan

create profile clerk limit

sessions_per_user 1

idle_time 30

connect_time 600;

CREATE TEMPORARY TABLESPACE TEMP_AH TEMPFILE 'C:\TEMP\TEMP_AH1.DBF'

SIZE 20M REUSE

EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;

CREATE TABLESPACE Data_AH DATAFILE 'c:\temp\data_ah1.dbf'

SIZE 1M EXTENT MANAGEMENT LOCAL

SEGMENT SPACE MANAGEMENT AUTO;

Step 1: create profile

Step 2: create temporary tablespace

Step 3: create temporary tablespace

LAB EXERCISE

Page 28: Create user  database management security

28 Chapter 3 - Dr. Girija Narasimhan

SQL> CREATE USER ahmed

2 IDENTIFIED BY ahmed

3 DEFAULT TABLESPACE DATA_AH

4 QUOTA 500K ON DATA_AH

5 TEMPORARY TABLESPACE TEMP_AH

6 PROFILE clerk;

User created.

Create default tablespace and

temporary tablespace.

Otherwise mention default

tablespace is “USERS” and

temporary tablespace “TEMP”.

Otherwise the below given error

will occur.

Step 4: create user LAB EXERCISE

Page 29: Create user  database management security

29 Chapter 3 - Dr. Girija Narasimhan

Create a Manager profile, Default tablespace Zahra_data, temporary tablespace

zahra_temp. And assign profile, default tablespace, temporary tablespace and

also assign quota 500k to user Zahra.

-Change default tablespce as USERS

-remove temporary tablespace zahra_temp

-Display temporary tablespce used by Zahra

-display all limits of MANAGER Profile

-display all the information of user Zahra

-Display only Quota information

-Delete Manager profile.

-assign a role staff to Zahra as default role

-revoke the quota

-change the password of zahra to flower

- Delete the user

CASE STUDY

Page 30: Create user  database management security

30 chapter 3 -Dr. Girija Narasimhan

Reference

Chapter 3 - Dr. Girija Narasimhan 30

Page 31: Create user  database management security

31 chapter 3 -Dr. Girija Narasimhan

The primary tablespace in any database is the SYSTEM

tablespace, which contains information basic to the

functioning of the database server, such as the data

dictionary and the system rollback segment.

The SYSTEM tablespace is the first tablespace created

at database creation.

It is managed as any other tablespace, but requires a

higher level of privilege and is restricted in some ways.

For example, you cannot rename or drop the SYSTEM

tablespace or take it offline.

SYSTEM tablespace

Chapter 3 - Dr. Girija Narasimhan 31

Page 32: Create user  database management security

32 chapter 3 -Dr. Girija Narasimhan

Temporary table spaces are used for special operations, particularly for

sorting data results on disk and for hash joins in SQL.

For SQL with millions of rows returned, the sort operation is too large for

the RAM area and must occur on disk. The temporary tablespace is where

this takes place.

Each database should have one temporary tablespace that is created

when the database is created.

You create, drop and manage tablespaces with create temporary

tablespace, drop temporary tablespace and alter temporary tablespace

commands.

Temporary table spaces

Chapter 3 - Dr. Girija Narasimhan 32

Page 33: Create user  database management security

Chapter 3 - Dr. Girija Narasimhan 33

Oracle® Database

Security Guide

11g Release 2 (11.2)

E36292-05

March 2014

This lecturer notes content prepared based on above given oracle database

security guide only.


Recommended