DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: cool script to clean db

  1. #1
    Join Date
    Jan 2001
    Posts
    216

    Question

    Is there a way to obtain a clean copy of the database to as it was when it was first created ?
    This will be very useful in testing scripts.

    One way is to write a custom cleanup script that undoes all that the test script had done. This can be cumbersome. Instead, it wll be cool if there is a simple standard script that cleans up and restores the database to the original clean state.

    Please let me know if you have any ideas.
    Thanks

  2. #2
    Join Date
    Sep 2000
    Posts
    47
    One easy way would be to use a backup (either online or offline).

    1. Create the database.
    2. Back it up (copying all the files to another directory is faster to restore, if you have the free space).
    3. When you want to return to the clean copy, just restore the files back.

    Tim

  3. #3
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    well I ont know what do you mean clean DB but | have a script to clean a schema's objects:

    Set linesize 100
    Set pagesize 0
    set head off feedback off verify off termout off Timing off time off
    Spool temp_drop.tmp
    Prompt spool drop_all.log
    Select Rtrim(
    'drop ' ||object_type||' '||
    object_name||decode(object_type,'TABLE',' cascade constraints ')
    || ';' )
    from user_objects
    Order by object_name
    /
    Prompt Spool off
    Spool off
    @temp_drop.tmp
    set pagesize 14
    Set head on feedback on verify on termout on
    exit

  4. #4
    Join Date
    Jan 2001
    Posts
    216
    By a clean DB, I mean a database as it was when it was first created by DB Config Asst.

    Right now, I am creating lots of scripts to create users, grant them privs, create tablespaces, tables, stored procedures, triggers, set up backup, set up oem, and so on. I want to test the scripts that I write a couple of times by re-running them on a clean database so that I have them correct and without errors.

    I think the backup idea would work. Thanks.

    Neelima

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width