Dynamically creating and executing sql commands in oracle
问题 I am taking a database class and at the beginning of the lab section of the class we usually have to drop all the tables in the database created previously. I wanted to be able to run a script that does this dynamically, but cannot seem to get it to work. Here is the code I have so far. declare tname string(50); cursor ctable is select table_name from user_tables; begin open ctable; LOOP FETCH ctable into tname; if tname != '' then execute immediate 'drop table ' || tname; END if; EXIT WHEN