I'm Top Oracle DBA

Generate script for drop user cascade for Oracle Databases 10g onward

User

Oracle Database doesn’t drop users whose schemas contain objects unless you specify CASCADE.

CASCADE

Specify CASCADE to drop all objects on the user’s(schemas) 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 Database 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.
  • If this point results in tables being dropped, then the database also drops all domain indexes created on columns of those tables and invokes appropriate drop routines.
***drop all user except system userĀ for test something then installing again in the same machine***

SELECT 'DROP USER '||USERNAME||' CASCADE;'
FROM DBA_USERS
WHERE USERNAME NOT IN (
'DBSNMP',
'SYSMAN',
'MGMT_VIEW',
'SYS',
'SYSTEM',
'FLOWS_FILES',
'MDSYS',
'ORDSYS',
'EXFSYS',
'SCOTT',
'WMSYS',
'ORACLE_OCM',
'APPQOSSYS',
'XS$NULL',
'APEX_030200',
'OWBSYS_AUDIT',
'MDDATA',
'ORDDATA',
'CTXSYS',
'ANONYMOUS',
'OUTLN',
'DIP',
'APEX_PUBLIC_USER',
'XDB',
'SPATIAL_CSW_ADMIN_USR',
'SPATIAL_WFS_ADMIN_USR',
'ORDPLUGINS',
'OWBSYS',
'SI_INFORMTN_SCHEMA',
'OLAPSYS',
'PUBLIC','TSMSYS') ORDER BY USERNAME;
error: Content is protected !!