Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / Oracle selected docs / SQL reference.pdf
Скачиваний:
24
Добавлен:
12.05.2015
Размер:
11.92 Mб
Скачать

CREATE ROLE

CREATE ROLE

Purpose

Use the CREATE ROLE statement to create a role, which is a set of privileges that can be granted to users or to other roles. You can use roles to administer database privileges. You can add privileges to a role and then grant the role to a user. The user can then enable the role and exercise the privileges granted by the role.

A role contains all privileges granted to the role and all privileges of other roles granted to it. A new role is initially empty. You add privileges to a role with the GRANT statement.

When you create a role that is NOT IDENTIFIED or is IDENTIFIED EXTERNALLY or BY password, Oracle grants you the role with ADMIN OPTION. However, when you create a role IDENTIFIED GLOBALLY, Oracle does not grant you the role.

See Also:

GRANT on page 17-29 for information on granting roles

ALTER USER on page 12-22 for information on enabling roles

ALTER ROLE on page 9-134 for information on modifying a role

DROP ROLE on page 16-97 for information on removing a role from the database

SET ROLE on page 18-47 for information on enabling and disabling roles for the current session

Oracle9i Heterogeneous Connectivity Administrator’s Guide for a detailed description and explanation of using global roles

Prerequisites

You must have CREATE ROLE system privilege.

SQL Statements: CREATE LIBRARY to CREATE SPFILE 14-79

CREATE ROLE

Syntax create_role::=

 

 

NOT

IDENTIFIED

 

 

 

 

 

 

BY

password

 

 

 

 

 

 

schema

.

 

 

IDENTIFIED

USING

 

package

 

 

 

 

 

 

 

 

 

EXTERNALLY

 

 

 

 

 

GLOBALLY

 

CREATE

ROLE

role

 

 

 

;

Semantics

role

Specify the name of the role to be created. Oracle recommends that the role contain at least one single-byte character regardless of whether the database character set also contains multibyte characters.

Some roles are defined by SQL scripts provided on your distribution media.

See Also: GRANT on page 17-29 for a list of these predefined roles

NOT IDENTIFIED Clause

Specify NOT IDENTIFIED to indicate that this role is authorized by the database and that no password is required to enable the role.

IDENTIFIED Clause

Use the IDENTIFIED clause to indicate that a user must be authorized by the specified method before the role is enabled with the SET ROLE statement.

BY password The BY password clause lets you create a local role and indicates that the user must specify the password to Oracle when enabling the role. The password can contain only single-byte characters from your database character set regardless of whether this character set also contains multibyte characters.

USING package The USING package clause lets you create an application role, which is a role that can be enabled only by applications using an authorized

14-80 Oracle9i SQL Reference

CREATE ROLE

package. If you do not specify schema, Oracle assumes the package is in your own schema.

EXTERNALLY Specify EXTERNALLY to create an external role. An external user must be authorized by an external service (such as an operating system or third-party service) before enabling the role.

Depending on the operating system, the user may have to specify a password to the operating system before the role is enabled.

GLOBALLY Specify GLOBALLY to create a global role. A global user must be authorized to use the role by the enterprise directory service before the role is enabled with the SET ROLE statement, or at login.

If you omit both the NOT IDENTIFIED clause and the IDENTIFIED clause, the role defaults to NOT IDENTIFIED.

Examples

Creating a Role: Example The following statement creates the role dw_manager:

CREATE ROLE dw_manager;

Users who are subsequently granted the dw_manager will inherit all of the privileges that have been granted to this role.

You can add a layer of security to roles by specifying a password, as in the following example:

CREATE ROLE dw_manager

IDENTIFIED BY warehouse;

Users who are subsequently granted the dw_manager role must specify the password warehouse to enable the role with the SET ROLE statement.

The following statement creates global role warehouse_user:

CREATE ROLE warehouse_user IDENTIFIED GLOBALLY;

The following statement creates the same role as an external role:

CREATE ROLE warehouse_user IDENTIFIED EXTERNALLY;

SQL Statements: CREATE LIBRARY to CREATE SPFILE 14-81

CREATE ROLLBACK SEGMENT

CREATE ROLLBACK SEGMENT

Purpose

Use the CREATE ROLLBACK SEGMENT statement to create a rollback segment, which is an object that Oracle uses to store data necessary to reverse, or undo, changes made by transactions.

The information in this section assumes that your database is running in rollback undo mode (the UNDO_MANAGEMENT initialization parameter is set to MANUAL or not set at all).

If your database is running in Automatic Undo Management mode (the UNDO_ MANAGEMENT initialization parameter is set to AUTO), then user-created rollback segments are irrelevant. In this case, Oracle returns an error in response to any

CREATE ROLLBACK SEGMENT or ALTER ROLLBACK SEGMENT statement. To suppress these errors, set the UNDO_SUPPRESS_ERRORS parameter to TRUE.

Further, if your database has a locally managed SYSTEM tablespace, then you cannot create rollback segments in any dictionary-managed tablespace. Instead, you must

Use the Automatic Undo Management feature, which uses undo tablespaces instead of rollback segments to hold undo data, or

Create locally managed tablespaces to hold the rollback segments.

Oracle Corporation recommends that you use Automatic Undo Management.

Notes:

A tablespace can have multiple rollback segments. Generally, multiple rollback segments improve performance.

The tablespace must be online for you to add a rollback segment to it.

When you create a rollback segment, it is initially offline. To make it available for transactions by your Oracle instance, bring it online using the ALTER ROLLBACK SEGMENT statement. To bring it online automatically whenever you start up the database, add the segment’s name to the value of the ROLLBACK_SEGMENTS initialization parameter.

14-82 Oracle9i SQL Reference

CREATE ROLLBACK SEGMENT

To use objects in a tablespace other than the SYSTEM tablespace:

If you are running the database in rollback undo mode, at least one rollback segment (other than the SYSTEM rollback segment) must be online.

If you are running the database in Automatic Undo Management mode, at least one UNDO tablespace must be online.

See Also:

ALTER ROLLBACK SEGMENT on page 9-136 for information on altering a rollback segment

DROP ROLLBACK SEGMENT on page 16-98 for information on removing a rollback segment

Oracle9i Database Reference for information on the UNDO_ MANAGEMENT and UNDO_SUPPRESS_ERRORS parameters

Oracle9i Database Administrator’s Guide for information on Automatic Undo Management mode

Prerequisites

To create a rollback segment, you must have CREATE ROLLBACK SEGMENT system privilege.

Syntax

create_rollback_segment::=

 

 

 

 

TABLESPACE

tablespace

 

PUBLIC

 

 

storage_clause

 

CREATE

ROLLBACK

SEGMENT

rollback_segment

 

;

(storage_clause::= on page 7-58)

Keyword and Parameters

PUBLIC

Specify PUBLIC to indicate that the rollback segment is public and is available to any instance. If you omit this clause, the rollback segment is private and is available only to the instance naming it in its initialization parameter ROLLBACK_SEGMENTS.

SQL Statements: CREATE LIBRARY to CREATE SPFILE 14-83

CREATE ROLLBACK SEGMENT

rollback_segment

Specify the name of the rollback segment to be created.

TABLESPACE

Use the TABLESPACE clause to identify the tablespace in which the rollback segment is created. If you omit this clause, Oracle creates the rollback segment in the SYSTEM tablespace.

Note: Oracle must access rollback segments frequently. Therefore, Oracle Corporation strongly recommends that you do not create rollback segments in the SYSTEM tablespace, either explicitly or implicitly (by omitting this clause). In addition, to avoid high contention for the tablespace containing the rollback segment, it should not contain other objects such as tables and indexes, and it should require minimal extent allocation and deallocation.

To achieve these goals, create rollback segments in locally managed tablespaces with autoallocation disabled—that is, in tablespaces created with the EXTENT MANAGEMENT LOCAL clause with the UNIFORM setting. (The AUTOALLOCATE setting is not supported.)

See Also:

CREATE TABLESPACE on page 15-80

Oracle9i Database Administrator’s Guide for more information on creating rollback segments and making them available

storage_clause

The storage_clause lets you specify storage characteristics for the rollback segment.

Notes:

The OPTIMAL parameter of the storage_clause is of particular interest, because it applies only to rollback segments.

You cannot specify the PCTINCREASE parameter of the storage_clause with CREATE ROLLBACK SEGMENT.

14-84 Oracle9i SQL Reference

CREATE ROLLBACK SEGMENT

See Also: storage_clause on page 7-56

Examples

Creating a Rollback Segment: Example The following statement creates a rollback segment with default storage values in an appropriately configured tablespace:

CREATE TABLESPACE rbs_ts

DATAFILE ’rbs01.dbf’ SIZE 10M

EXTENT MANAGEMENT LOCAL UNIFORM SIZE 100K;

/* This example and the next will fail if your database is in Automatic Undo Mode.

*/

CREATE ROLLBACK SEGMENT rbs_one TABLESPACE rbs_ts;

The preceding statement is equivalent to the following:

CREATE ROLLBACK SEGMENT rbs_one TABLESPACE rbs_ts

STORAGE

( INITIAL 10K

NEXT 10K

MAXEXTENTS UNLIMITED);

SQL Statements: CREATE LIBRARY to CREATE SPFILE 14-85

Соседние файлы в папке Oracle selected docs