OR use TOAD or Oracle EM
Reader, October 30, 2007 - 11:22 am UTC
that will give you create user script with all the grants, object and system privs. These days GUI tools are good to extract scripts.
Approach
Phil Winfield, October 30, 2007 - 1:10 pm UTC
Guess so but my reason is for a deinstall option on an APEX app. The script needs to drop all tables and I thought it would be easier to ressurrect this script. I've managed to get around by just doing a for loop with execute immediate in the middle for all tables (with cascade constraints) and sequences and then a series of drop statements for the remaining objects. APEX v3 should really permit multiple de-install scripts in the same way we have multiple install scripts.
Phil
cleanschema.sql
Balaji, October 30, 2007 - 1:59 pm UTC
Guys,
I use the following script to cleanup the schema.
Since I use "CASCADE CONSTRAINTS" for table it doesn't throw me an error.
--------------------------------------------------------------------
set feedback off
set heading off
set termout off
set linesize 1000
set trimspool on
set verify off
spool c:\temp\drop_objects.lst
SELECT 'DROP ' || OBJECT_TYPE || ' ' || OBJECT_NAME ||';' FROM USER_OBJECTS
WHERE OBJECT_TYPE <> 'TABLE' AND OBJECT_TYPE <> 'INDEX' AND OBJECT_TYPE<>'PACKAGE BODY' AND OBJECT_TYPE<>'TRIGGER' AND OBJECT_TYPE<>'LOB'
UNION ALL
SELECT 'DROP ' || OBJECT_TYPE || ' ' || OBJECT_NAME ||' CASCADE CONSTRAINTS;' FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'TABLE';
spool off;
@c:\temp\drop_objects.lst
prompt 'Purging the recycle bin...'
purge recyclebin;
host del c:\temp\drop_objects.lst
exit;
may help
T. Charlton, February 07, 2008 - 1:13 pm UTC
SET PAGES 0 TRIMS ON ECHO OFF VERIFY OFF FEEDBACK OFF
PROMPT
PROMPT ***** DROP all tables *****
PROMPT
SPOOL drop_tables.sql
SELECT 'SET ECHO ON TIME ON' FROM dual;
SELECT 'SPOOL drop_tables.log' FROM dual;
SELECT '' FROM dual;
SELECT 'DROP TABLE '||owner||'.'||table_name||';'
FROM dba_tables
WHERE owner='&1'
/
SELECT '' FROM dual;
SELECT 'SPOOL OFF' FROM dual;
SELECT 'SET ECHO OFF TIME OFF' FROM dual;
SPOOL OFF
SET PAGES 999 TRIMS ON ECHO OFF VERIFY ON FEEDBACK ON
PROMPT
PROMPT *******************************
PROMPT
PROMPT Output saved at drop_tables.sql
PROMPT