TT22

Untitled

Sep 13th, 2017
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.45 KB | None | 0 0
  1. BEGIN
  2.    FOR cur_rec IN (SELECT object_name, object_type
  3.                      FROM user_objects
  4.                     WHERE object_type IN
  5.                              ('TABLE',
  6.                               'VIEW',
  7.                               'PACKAGE',
  8.                               'PROCEDURE',
  9.                               'FUNCTION',
  10.                               'SEQUENCE',
  11.                               'SYNONYM',
  12.                               'PACKAGE BODY'
  13.                              ))
  14.    LOOP
  15.       BEGIN
  16.          IF cur_rec.object_type = 'TABLE'
  17.          THEN
  18.             EXECUTE IMMEDIATE    'DROP '
  19.                               || cur_rec.object_type
  20.                               || ' "'
  21.                               || cur_rec.object_name
  22.                               || '" CASCADE CONSTRAINTS';
  23.          ELSE
  24.             EXECUTE IMMEDIATE    'DROP '
  25.                               || cur_rec.object_type
  26.                               || ' "'
  27.                               || cur_rec.object_name
  28.                               || '"';
  29.          END IF;
  30.       EXCEPTION
  31.          WHEN OTHERS
  32.          THEN
  33.             DBMS_OUTPUT.put_line (   'FAILED: DROP '
  34.                                   || cur_rec.object_type
  35.                                   || ' "'
  36.                                   || cur_rec.object_name
  37.                                   || '"'
  38.                                  );
  39.       END;
  40.    END LOOP;
  41. END;
  42. /
Advertisement
Add Comment
Please, Sign In to add comment