Skip to content

Instantly share code, notes, and snippets.

@FleXoft
Created November 30, 2018 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FleXoft/9e6c1bea9c0167bf6c099a9a6bc87475 to your computer and use it in GitHub Desktop.
Save FleXoft/9e6c1bea9c0167bf6c099a9a6bc87475 to your computer and use it in GitHub Desktop.
Oracle loop
DECLARE CURSOR c_drop IS
SELECT table_name
FROM dba_tables
WHERE owner = '<sm séma neve>';
v_sql VARCHAR2(800);
BEGIN
FOR r IN c_drop
LOOP
v_sql := 'DROP TABLE '|| r.owner||'.'|| r.table_name||' cascade constraints' to prx_test';
dbms_output.put_line(v_sql);
BEGIN
EXECUTE IMMEDIATE v_sql;
EXCEPTION WHEN OTHERS THEN dbms_output.put_line(dbms_utility.format_error_backtrace );
END;
END LOOP;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment