Generate script to delete all schemas

Hello All,
I'm going to do a reimport and i want to delete all the schemas in the db....
I've written this script:
select 'DROP TABLE schemaname.' || TABLE_NAME || ' CASCADE CONSTRAINTS;'
from dba_tables
where owner = 'schemaname'
order by TABLE_NAME;
how can i generate the script for all the schemas? The above will only list one schema...
Basically i want to do another import and get a clean log (as clean as possible).
Thanks.

You modify your query to select a distinct list of object owners. In fact you might want to look for some other objects besides tables. If you are only interested in tables you should probably change the subquery to look at dba_tables.
select 'DROP TABLE '||owner||'.' || TABLE_NAME || ' CASCADE CONSTRAINTS;'
from dba_tables
where owner in (select distinct owner from dba_objects
where owner not in ('SYS','SYSTEM','OUTLN','PUBLIC')
order by TABLE_NAME;
You should look the list of owners over very carefully before running the resulting DDL commands. There are other owners, depending on your Oracle version and features in use, that you will not want to touch.
HTH -- Mark D Powell --

Similar Messages

  • Script that deletes all the data in the DB

    Somebody has or know a script that delete all the data (but not the tables) of the database???? I have dummy data and know I need the tables clean of data.
    How can I delete it???????? Thank you for you help
    Javier

    You could truncate all the tables with the following commandTRUNCATE TABLE <table_name>;This will delete all the data in the table while keeping the table structure, contraints, indexes, triggers, etc. intact so they wont have to be rebuilt. All foreign keys must be disabled to use the TRUNCATE command.

  • Script to delete all attachments

    Hi all
    I was wondering whether there is a script to delete all of the attachments in a pdf form? I know that you can use removeDataObject to delete specific attachments by name, but was wondering whether there was a simple way to delete all of the attachments in one hit?
    Cheers
    Mark

    You just need to loop through the dataObject.
    // DUMP ANY ATTACHMENTS
    var d = event.target.dataObjects;
    if (d != null)
    for (var i = 0; i < d.length; i++)
    // console.println("Data Object[" + i + "]=" + d[i].name);
    event.target.removeDataObject(d[i].name);

  • A script to delete all table rows containing a specific text

    Hello,
    I've tried some old scripts but can't get around to the right solution.
    I need a script that will delete all rows in a table that contain a specific single-word text, something like "xxx".
    Anyone's got an idea?
    Thanks

    Hi,
    To remove a row use row.remove() method.
    So iterate through table.rows and remove the one matched a condition.
    If we talk about condition you have to be more accurate - what do you mean "a row contain a text":
         ==> 1st cell contains,
         ==> any cell contains.
    Entire row contents is an array of its cells.contents, so your 1st row text is:
    rows[0].contents.join(" ")     ==> string
    Jarek

  • How can I create a script to delete all Layer Comps?

    I know this has to be pretty easy but I'm flummoxed on the syntax. Thanks, in advance!

    // 2012, use it at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    while (myDocument.layerComps.length > 0) {
    myDocument.layerComps[0].remove()

  • Deleting all instances of a particular composite using scripts

    Hi,
    I am trying to delete all the instances for a particular composite id in Linux. I got some reference to some script in user guide as below
    Deleting Composite Instances, Rejected Messages, and Orphaned Instances
    This procedure internally invokes the procedures for deleting composite instances, rejected messages, and orphaned instances. This procedure is convenient for deleting all composite instances, rejected messages, and orphaned instances in a single invocation.
    FABRIC.DELETE_ALL(FILTER IN INSTANCE_FILTER,
    MAX_INSTANCES IN INTEGER,
    PURGE_PARTITIONED_DATA IN BOOLEAN DEFAULT TRUE) RETURN INTEGER;
    The following example deletes composite instances, rejected messages, and orphaned instances based on the specified filter.
    DECLARE
    FILTER INSTANCE_FILTER := INSTANCE_FILTER();
    MAX_INSTANCES NUMBER;
    DELETED_INSTANCES NUMBER;
    BEGIN
    FILTER.COMPOSITE_PARTITION_NAME:='default';
    FILTER.COMPOSITE_NAME := 'OrderBookingComposite';
    FILTER.COMPOSITE_REVISION := '1.0';
    FILTER.STATE := fabric.STATE_COMPLETED_SUCCESSFULLY;
    FILTER.MIN_CREATED_DATE := to_timestamp('2009-07-01','YYYY-MM-DD');
    FILTER.MAX_CREATED_DATE := to_timestamp('2009-08-24','YYYY-MM-DD');
    MAX_INSTANCES := 100;
    DELETED_INSTANCES := FABRIC.DELETE_ALL(
    FILTER => FILTER,
    MAX_INSTANCES => MAX_INSTANCES
    END;
    But how do I use it. Should I just run @purge_fabric_oracle.sql and will it prompt for parameters. Also Is this the right script to delete all the instances.
    Regards
    Edited by: user5108636 on 22/06/2010 16:53

    For deletion scripts I am particularly cautious. I want to delete all the instances for a particular composite id. How do I get the composite id. ProcessData [1.0] is shown in the EM under the soa application tree. Is it the composite id.
    Thanks

  • Script to Delete more than 1 user from the database

    Hi All,
    I have a list of users in a file and i want to write a script to delete all these
    users from my database.
    I have tried deleting users using:
    drop user user1,user2,user3..... but it doesn't seem to work.
    Can anyone suggest how do i read the users from the file and delete them one by one

    You can use an external table :
    SYS@db102 SQL> select username from all_users
      2  where username like 'USER%';
    USERNAME
    USER1
    USER2
    USER3
    SYS@db102 SQL> !cat users_to_drop.txt
    USER1
    USER2
    USER3
    SYS@db102 SQL> create table test.users_to_drop
      2  (
      3     userx   char(30)
      4  )
      5    organization external
      6  ( type oracle_loader
      7    default directory work
      8    access parameters
      9     ( records delimited by newline
    10     )
    11     location ('users_to_drop.txt')
    12  )
    SYS@db102 SQL> /
    Table created.
    SYS@db102 SQL> begin
      2     for U in (select userx from test.users_to_drop) loop
      3             dbms_output.put_line('Dropping '||U.userx);
      4             execute immediate 'drop user '||U.userx||' cascade';
      5     end loop;
      6  end;
    SYS@db102 SQL> /
    Dropping USER1
    Dropping USER2
    Dropping USER3
    PL/SQL procedure successfully completed.
    SYS@db102 SQL> select username from all_users
      2  where username like 'USER%';
    no rows selected
    SYS@db102 SQL>

  • Script for deleting objects on pasteboard

    Anyone have a script that deletes all objects and text outside the page (or margins)?

    Unfortunately in my Indi CS6 any pasteboard and spread item is "instance of spread".
    So i consider geometrical bounds:
    myDocument = app.activeDocument
    cur_Ruler = myDocument.viewPreferences.rulerOrigin;
    with(myDocument.viewPreferences){
        rulerOrigin = RulerOrigin.spreadOrigin;}
    myDocument.zeroPoint = [0,0];
    aWidth = myDocument.documentPreferences.pageWidth*2+10;
    var objs = app.documents[0].pageItems.everyItem().getElements();
    while(obj=objs.pop()){
    a_left = obj.geometricBounds[1];
    a_right = obj.geometricBounds[3];
         if(a_right <0 || a_left > aWidth){obj.remove()}
    with(myDocument.viewPreferences){
        rulerOrigin = cur_Ruler} //back to the RulerOrigin

  • Script to delete expired or errored scheduled workbooks for Discoverer

    Hi All,
    Can any one pont me to find a script to delete all expired and Errored workbooks in Database for discoverer?
    Appreciate all your assistance.
    Thankks
    -S

    Hi Asim,
    I don't think you can share the results of the scheduled workbook using Desktop. As for Plus, when you're signed on as the other user are you in the same database & eul and are you looking for "scheduled workbooks"?
    Brent

  • Using Powershell to delete all users from the Portal

    Summary
    This script will delete all users from the Portal except for Administrator and the Built-In Sync account.
    Based on Markus's "Delete a User" script.
    Useful when developing your system if you want to quickly clear out the data and start again.
    set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant
    function DeleteObject
    PARAM($objectType, $objectId)
    END
    $importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
    $importObject.ObjectType = $objectType
    $importObject.TargetObjectIdentifier = $objectId
    $importObject.SourceObjectIdentifier = $objectId
    $importObject.State = 2
    $importObject | Import-FIMConfig -uri $URI
    if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
    $allobjects = export-fimconfig -uri $URI `
    –onlyBaseResources `
    -customconfig "/Person"
    $allobjects | Foreach-Object {
    $displayName = $_.ResourceManagementObject.ResourceManagementAttributes | `
    Where-Object {$_.AttributeName -eq "DisplayName"}
    if([string]::Compare($displayName.Value, "Administrator", $True) -eq 0)
    {write-host "Administrator NOT deleted"}
    elseif([string]::Compare($displayName.Value, "Built-in Synchronization Account", $True) -eq 0)
    {write-host "Built-in Synchronization Account NOT deleted"}
    else {
    $objectId = (($_.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
    DeleteObject -objectType "Person" `
    -objectId $objectId
    write-host "`nObject deleted`n" $displayName.Value }
    Go to the FIM ScriptBox
    http://www.wapshere.com/missmiis

    The DeleteObject function opens and closes a connection for each object.  This approach is faster:
    http://social.technet.microsoft.com/wiki/contents/articles/23570.how-to-use-powershell-to-delete-fim-users-that-have-a-null-attribute-name.aspx
    Mike Crowley | MVP
    My Blog --
    Planet Technologies

  • Apple script to delete user home folder

    I wish to run a appple script to delete all user home folders except for ladmin which is an admin account. All other user home folders need to go. Any one have a script that can do this by using ARD

    Account information is kept in NetInfo, a complex system database. If you just delete a home folder the account will still exist, and a new home folder will be created the next time a user logs into it.

  • Delete generated script

    hi,
    I'm quite new to APEX and I tried to generate ddl of my schema, which was not a problem at all. But I chose to save it on file, which then generates a script.
    The problem is that I cannot open this script in the editor, beacuse my browser (both mozilla and ie7) hang.
    When I try to delete this generated script, it takes so long, that I canceled the delete option. Is there another way to delete this script?
    tnx in advance!

    Hello
    If you're using Windows, have you tried (SHIFT+DEL)
    This will DELETE a file as opposed to sending it to your Recycling Bin (which may be taking time).
    The only point worth mentioning here is that a SHIFT+DEL really does Delete a file. You won't be able to get it back.
    Kind regards
    Simon

  • How to delete all rows in all tables of a schema in Oracle?

    Hi all,
    I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
    may you help?
    Edited by: user8105261 on Nov 25, 2009 11:06 PM

    user8105261 wrote:
    Hi all,
    I want to delete all records of all tables of a schema and I think there should be some statement for this but I don't know how?
    may you help?
    Edited by: user8105261 on Nov 25, 2009 11:06 PMA typical way to reset a schema (e.g. to recreate a schema on the test database) is totally different.
    1) Drop the user
    2) recreate the user including table scripts from
    2a) your version control system
    2b) from a export dumpfile using the "nodata" option while importing

  • Request in steps in deleting all the tables data in an user schema.

    Hi Gurus,
    Could some one please provide me the steps involved in deleting all the tables data in an user(schema)
    thanks in advance

    write a script as below
    sys@11GDEMO> select 'truncate table '||owner||'.'||table_name||';' from dba_tables where owner='SCOTT';
    'TRUNCATETABLE'||OWNER||'.'||TABLE_NAME||';'
    truncate table SCOTT.DEPT;
    truncate table SCOTT.EMP;
    truncate table SCOTT.BONUS;
    truncate table SCOTT.SALGRADE;
    truncate table SCOTT.EMPBACKUP;
    truncate table SCOTT.T_NAME;
    truncate table SCOTT.D_TEMP_STSC;
    Example:
    sys@11GDEMO> truncate table SCOTT.T_NAME;
    Table truncated.
    sys@11GDEMO>

  • Generate a script to recreate all grants

    Hi anybody has a script to generate the grants for all database? grants ike this example :
    ..........ablespace Quotas for CANTOR
    ALTER USER CANTOR QUOTA UNLIMITED ON CV_TEMP;
    ALTER USER CANTOR QUOTA UNLIMITED ON CV_DATA;
    -- 166 Object Privileges for CANTOR
    GRANT EXECUTE ON FRSQ.FFFR TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRAVI_INT TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRBOBF2 TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRBOBMPST TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRBOCBCJ TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRBOCN TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRBOTERM TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRDIRBF TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRDIRCBCJ TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRDIRCN TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRDIRTERM TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRLET_INT TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRLST TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRSUBFA TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRSUBFF TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRSUBPFIZ TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRSUBPR TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRSUBRITS TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRSUBTERM TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFFRVAL TO CANTOR;
    GRANT EXECUTE ON FRSQ.FFUTIL TO CANTOR;
    GRANT SELECT ON FRSQ.INFO_DEMANDE TO CANTOR;
    GRANT SELECT ON FRSQ.INFO_PROGRAMME TO CANTOR;
    GRANT DELETE, INSERT, SELECT, UPDATE ON GDEM.ACCES_DOSSIER TO CANTOR;
    GRANT SELECT ON GDEM.ACCES_NON_AUTORISE TO CANTOR;
    GRANT EXECUTE ON GDEM.ACCES_UDA TO CANTOR;
    GRANT SELECT ON GDEM.AUDIT_ACCES TO CANTOR;
    GRANT EXECUTE ON GDEM.COMPOSITION_EQUIPE TO CANTOR;
    GRANT EXECUTE ON GDEM.COMPOSITION_EQUIPE_LI TO CANTOR;
    GRANT SELECT ON GDEM.COMPOSITION_LI TO CANTOR;
    GRANT SELECT, UPDATE ON GDEM.COMPOSITION_SUBV TO CANTOR;
    GRANT SELECT, UPDATE ON GDEM.COMPO_TEMP TO CANTOR;
    GRANT SELECT ON GDEM.COURRIEL_SEQ TO CANTOR;
    GRANT SELECT ON GDEM.DATE_LIMITE TO CANTOR;
    GRANT SELECT ON GDEM.DATE_LIMITE TO CANTOR;
    GRANT SELECT ON GDEM.DATE_LIMITE_BR TO CANTOR;
    GRANT REFERENCES, SELECT ON GDEM.DEMANDE TO CANTOR;
    GRANT REFERENCES, SELECT ON GDEM.DEM_LI TO CANTOR;
    GRANT SELECT ON GDEM.DOCUMENT_FCAR TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFR TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACB3 TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACBO TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACDE TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACDEL TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACDELSC TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACDESC TO CANTOR;
    GRANT EXECUTE ON GDEM.FAFRACNP TO CANTOR;
    Edited by: Jpmill on Aug 7, 2009 11:05 AM

    Hi.
    Then use all these below views to get the grants:-
    ALL_TAB_PRIVS          All object grants where the user or public is grantee
    ALL_TAB_PRIVS_MADE     All object grants made by user or on user owned objects
    ALL_TAB_PRIVS_RECD     All object grants to user or public
    DBA_SYS_PRIVS          System privileges granted to users and roles
    DBA_ROLES          List of all roles in the database
    DBA_ROLE_PRIVS          Roles granted to users and to other roles
    ROLE_ROLE_PRIVS          Roles granted to other roles
    ROLE_SYS_PRIVS          System privileges granted to roles
    ROLE_TAB_PRIVS          Table privileges granted to roles
    SESSION_PRIVS          All privileges currently available to user
    SESSION_ROLES          All roles currently available to user
    USER_SYS_PRIVS          System privileges granted to current user
    USER_TAB_PRIV          Grants on objects where current user is grantee, grantor, or ownerAnand

Maybe you are looking for

  • Using Polaroid HD-LCD tv as Mini display...NOT! :(

    Very similar symptoms as described in the post re: ENVISON wide scieen. Well, maybe not exactly...tv is 19" Poloroid TLA-01911C w/ oodles of inpiut options like most other brands. I opened the box attached a VGA cable to the tv, powered up tv and min

  • Transfer of contacts from 8300 to 9900 via BB desktop

    I can't connect my 8300 to bb desktop because the connector/charging port on the phone has developed a fault so can't back it up to transfer data to my new 9900. I do have a back up from June as an IPD file. If I connect the 9900 can I access this IP

  • Dreamweaver CC Crashing When Editing Files

    I just wanted to post this to let anyone know who may be having this problem too. Dreamweaver CC was crashing for me when I would open a file, edit it and save and put it. I read all the discussions saying it was an issue with not having the Verdana

  • Cross-application sharing problem in Application Server(OC4J)

    I use OC4J 9.0.3 version. Cross-application sharing. The "parent" declaration is made in the <application> tag within server.xml. these appear as follows: <application name="A" path="a.ear" /> <application name="B" path="b.ear" parent="A" /> The stru

  • My MacMini does not stop after giving the order ''switch off''.What can I do?

    My MacMini does not stop after giving the order ''switch off''. It stops only, after pushing the button ''on/off'' for some seconds. What can I do? frahsun