Scripting Examples

Loop Example

BEGIN

FOR c1 in ([SELECT field1, field2 FROM table1])
LOOP
dbms_output.put_line('Field1 ' || c1.field1);
dbms_output.put_line('Field2 ' || c1.field2);
END LOOP;

END;
/

Loop Through All Tables

BEGIN

FOR c1 in (SELECT TABLE_NAME
FROM USER_TABLES)
LOOP
dbms_output.put_line('Dropping ' || c1.table_name);
execute immediate 'drop table ' || c1.table_name || ' cascade constraints';
END LOOP;

END;
/