Home > Database > Oracle > body text

How to delete all tables under a user in Oracle?

青灯夜游
Release: 2020-09-30 09:50:06
Original
16184 people have browsed it

Method: 1. Use the "drop user user_name cascade;" statement; 2. Use the "select 'drop table '||table_name||';' from cat where table_type='TABLE'" statement.

How to delete all tables under a user in Oracle?

ORACLE method of deleting all tables under the current user

1 . If you have the permission to delete the user, you can:

drop user user_name cascade;
Copy after login

After adding cascade, you can delete all the data associated with the user.

Delete and then create this user.

--Create administrator user

create user 用户名 identified by 密码 default tablespace space_data(表空间名称) temporary tablespace space_temp(临时表空间名称);
Copy after login

--Authorization

grant connect,dba to 用户名;
Copy after login

--Modify quota

ALTER USER "用户名" QUOTA UNLIMITED ON SPACE_DATA(表空间名称);
Copy after login

--View all user objects

select uo.object_name,uo.object_type from user_objects uo where uo.object_type<>&#39;LOB&#39; order by uo.object_type desc
Copy after login

2. If you do not have the permission to delete the user, you can execute:

select &#39;drop table &#39;||table_name||&#39;;&#39;
from cat
where table_type=&#39;TABLE&#39;
Copy after login

A batch of sql statements for deleting the table will be output. Just execute these SQL statements. (Requires permission to drop table)

Recommended tutorial: "Oracle Tutorial"

The above is the detailed content of How to delete all tables under a user in Oracle?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template