Search
 
SCRIPT & CODE EXAMPLE
 

SQL

drop all database tables oracle sql developer

BEGIN
   FOR cur_rec IN (SELECT object_name, object_type
                   FROM user_objects
                   WHERE object_type IN
                             ('TABLE',
                              'VIEW',
                              'MATERIALIZED VIEW',
                              'PACKAGE',
                              'PROCEDURE',
                              'FUNCTION',
                              'SEQUENCE',
                              'SYNONYM',
                              'PACKAGE BODY'
                             ))
   LOOP
      BEGIN
         IF cur_rec.object_type = 'TABLE'
         THEN
            EXECUTE IMMEDIATE 'DROP '
                              || cur_rec.object_type
                              || ' "'
                              || cur_rec.object_name
                              || '" CASCADE CONSTRAINTS';
         ELSE
            EXECUTE IMMEDIATE 'DROP '
                              || cur_rec.object_type
                              || ' "'
                              || cur_rec.object_name
                              || '"';
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line ('FAILED: DROP '
                                  || cur_rec.object_type
                                  || ' "'
                                  || cur_rec.object_name
                                  || '"'
                                 );
      END;
   END LOOP;
   FOR cur_rec IN (SELECT * 
                   FROM all_synonyms 
                   WHERE table_owner IN (SELECT USER FROM dual))
   LOOP
      BEGIN
         EXECUTE IMMEDIATE 'DROP PUBLIC SYNONYM ' || cur_rec.synonym_name;
      END;
   END LOOP;
END;
/
Comment

PREVIOUS NEXT
Code Example
Sql :: psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user 
Sql :: psql import backup file for windows 
Sql :: Oracle Column Names of a table 
Sql :: postgresql get year 
Sql :: view linked servers sql 
Sql :: ksql terminate all queries 
Sql :: login to database mysql terminal 
Sql :: sql myisam vs innodb 
Sql :: mysql select last row for each group 
Sql :: oracle alter table add column not null 
Sql :: mysql root localhost run 
Sql :: how to select all attributes from a row if there is a certain string in it MySQL 
Sql :: date 3 months from today sql 
Sql :: grant all priviledges to mysql user 
Sql :: mysql remove user privileges 
Sql :: sql server cannot create database diagram 
Sql :: if not exists insert sql 
Sql :: mysql previous year 
Sql :: sql last updated 
Sql :: sql update from different table 
Sql :: how to create table in sql 
Sql :: how to search date in sql query 
Sql :: Insert from table tsql 
Sql :: oracle list duplicates 
Sql :: allsource oracle 
Sql :: postgresql how to show table names 
Sql :: Get Minimum from multiple columns sql 
Sql :: Configure postgresql engine for your django application 
Sql :: postgresql cast 
Sql :: sql limit results returned 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =