set lines 200 col owner format a20 col username format a30 col schema format a30 PROMPT =================================================== PROMPT List of all schemas and number of Objects they own: PROMPT =================================================== select u.username "Schema", decode(count(*),1,0, count(*)) "Number of Objects" from dba_users u left outer join dba_objects o on u.username = o.owner where u.username in (USER1','USER2','USER3') group by u.username order by username ASC; set heading off set trimspool on set lines 200 set feedback off spool drop_users.sql select 'spool drop_users_SD4440.log' from dual; select 'DROP USER ' || u.username || DECODE(decode(count(*),1,0, count(*)), '0',';' , ' CASCADE;') from dba_users u left outer join dba_objects o on u.username = o.owner where u.username in ('USER1','USER2','USER3') group by u.username; select 'exit' from dual; exit
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
Tuesday, December 22, 2015
Generate "drop user" statement for schemas with and without objects
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment