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

DROP USER

DROP USER

Purpose

Use the DROP USER statement to remove a database user and optionally remove the user’s objects.

See Also:

CREATE USER on page 16-32 for information on creating a user

ALTER USER on page 12-22 for information on modifying the definition of a user

Prerequisites

You must have the DROP USER system privilege.

Syntax

drop_user::=

 

 

 

CASCADE

DROP

USER

user

;

Semantics

user

Specify the user to be dropped. Oracle does not drop users whose schemas contain objects unless you specify CASCADE or unless you first explicitly drop the user’s objects.

CASCADE

Specify CASCADE to drop all objects in the user’s schema before dropping the user. You must specify this clause to drop a user whose schema contains any objects.

If the user’s schema contains tables, then Oracle drops the tables and automatically drops any referential integrity constraints on tables in other schemas that refer to primary and unique keys on these tables.

17-20 Oracle9i SQL Reference

DROP USER

If this clause results in tables being dropped, then Oracle also drops all domain indexes created on columns of those tables and invokes appropriate drop routines.

See Also: Oracle9i Data Cartridge Developer’s Guide for more information on these routines

Oracle invalidates, but does not drop, the following objects in other schemas: views or synonyms for objects in the dropped user’s schema; and stored procedures, functions, or packages that query objects in the dropped user’s schema.

Oracle does not drop materialized views in other schemas that are based on tables in the dropped user’s schema. However, because the base tables no longer exist, the materialized views in the other schemas can no longer be refreshed.

Oracle drops all triggers in the user’s schema.

Oracle does not drop roles created by the user.

Caution: Oracle also drops with FORCE all types owned by the user. See the FORCE keyword of DROP TYPE on page 17-16.

Examples

Dropping a Database User: Example If user Sidney’s schema contains no objects, then you can drop sidney by issuing the statement:

DROP USER sidney;

If Sidney’s schema contains objects, then you must use the CASCADE clause to drop sidney and the objects:

DROP USER sidney CASCADE;

SQL Statements: DROP SEQUENCE to ROLLBACK 17-21

DROP VIEW

DROP VIEW

Purpose

Use the DROP VIEW statement to remove a view or an object view from the database. You can change the definition of a view by dropping and re-creating it.

See Also:

CREATE VIEW on page 16-39 for information on creating a view

ALTER VIEW on page 12-31 for information on modifying a view

Prerequisites

The view must be in your own schema or you must have the DROP ANY VIEW system privilege.

Syntax

drop_view::=

 

schema

.

CASCADE

CONSTRAINTS

DROP

VIEW

view

 

;

Semantics

schema

Specify the schema containing the view. If you omit schema, then Oracle assumes the view is in your own schema.

view

Specify the name of the view to be dropped.

Oracle does not drop views, materialized views, and synonyms that refer to the view but marks them INVALID. You can drop them or redefine views and synonyms, or you can define other views in such a way that the invalid views and synonyms become valid again.

17-22 Oracle9i SQL Reference

DROP VIEW

If any subviews have been defined on view, then Oracle invalidates the subviews as well. To learn if the view has any subviews, query the SUPERVIEW_NAME column of the USER_, ALL_, or DBA_VIEWS data dictionary views.

See Also:

CREATE TABLE on page 15-7 and CREATE SYNONYM on page 15-2

ALTER MATERIALIZED VIEW on page 9-90 for information on revalidating invalid materialized views

CASCADE CONSTRAINTS

Specify CASCADE CONSTRAINTS to drop all referential integrity constraints that refer to primary and unique keys in the view to be dropped. If you omit this clause, and such constraints exist, then the DROP statement will fail.

Example

Dropping a View: Example The following statement drops the emp_view view "Creating a View: Example" on page 16-50):

DROP VIEW emp_view;

SQL Statements: DROP SEQUENCE to ROLLBACK 17-23

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