Cursor Delete table

 Local temporary tables are too many useless test database, with circulation drop table

 

. 1  DECLARE  
2   
. 3    - I Integer; 
. 4    v_tablename VARCHAR2 ( 20 is );
 . 5    v_sql VARCHAR2 ( 200 is ); - definition table name 
. 6    CURSOR emp_cursor the IS  SELECT TABLE_NAME   from USER_TAB_COMMENTS; - cursor 
. 7  the begin 
. 8     - SELECT TABLE_NAME from USER_TAB_COMMENTS - - the name of the current user query table 
9    open emp_cursor;                                               - open the cursor 
10   Loop                                                            - Open loop 
. 11    the FETCH   emp_cursor INTO v_tablename;                            - value 
12 is      the EXIT  the WHEN emp_cursor % NOTFOUND;                                - Analyzing cursor loop 
13 is    - DBMS_OUTPUT.PUT_LINE (v_tablename); --dbsm outputs the print table 
14    v_sql: = ' drop table ' || v_tablename;                             - splicing table statement deleted deleted drop table space without the commit 
15    DBMS_OUTPUT.PUT_LINE (v_sql);
16    Execute immediate v_sql;                                        - execute sql statement 
. 17    End Loop;                                                       - Mark end of cycle 
18 is    the CLOSE emp_cursor;                                               - closing the cursor 
. 19  End ;

 

Guess you like

Origin www.cnblogs.com/Isolate/p/11826364.html