Using DROP USER statement in Oracle

This article is written about how to use the Oracle DROP USER statement with syntax and examples.

Description

The DROP USER announcement is used to get rid of a consumer from the Oracle database and dispose of all objects owned by that user.

Syntax

The syntax for the DROP USER assertion in Oracle/PLSQL is:

DROP USER user_name [ CASCADE ];

Parameters or Arguments

user_name The title of the consumer to put off from the Oracle database. CASCADE Optional. If user_name owns any objects (ie: tables or views in its schema), you need to specify CASCADE to drop all of these objects.

Example

Let’s look at a simple DROP USER statement.

If the consumer does now not own any objects in its schema, you may want to execute the following DROP USER statement:

DROP USER smithj;

This would drop the consumer called smithj. This DROP USER declaration will only run if smithj does now not personal any objects in its schema.

If smithj did very own objects in its schema, you would want to run the following DROP USER declaration instead:

DROP USER smithj CASCADE;

This DROP USER assertion would put off the consumer smithj, drop all objects (ie: tables and views) owned by using smithj, and all referential integrity constraints on smithj’s objects would additionally be dropped.