【Oracle】批量删除表
sqlSET SERVEROUTPUT ON;DECLARELNAME VARCHAR2(200);BEGINFOR X IN (select TABLE_NAME from user_tableswhere table_name like 'SYMPHONY%') LOOPLNAME:= X.TABLE_NAME;EXECUTE IMMEDIATE 'DROP TABLE '|| X
·
sql
SET SERVEROUTPUT ON;
DECLARE
LNAME VARCHAR2(200);
BEGIN
FOR X IN (select TABLE_NAME from user_tables
where table_name like 'SYMPHONY%'
) LOOP
LNAME:= X.TABLE_NAME;
EXECUTE IMMEDIATE 'DROP TABLE '|| X.TABLE_NAME ;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line(LNAME);
RAISE;
END;
/
执行结果
SQL> SET SERVEROUTPUT ON;
SQL> DECLARE
2 LNAME VARCHAR2(200);
3 BEGIN
4 FOR X IN (select TABLE_NAME from user_tables
5 where table_name like 'SYMPHONY%'
6 ) LOOP
7 LNAME:= X.TABLE_NAME;
8 EXECUTE IMMEDIATE 'DROP TABLE '|| X.TABLE_NAME ;
9 END LOOP;
10 EXCEPTION
11 WHEN OTHERS THEN
12 DBMS_OUTPUT.put_line(LNAME);
13 RAISE;
14 END;
15 /
PL/SQL procedure successfully completed
更多推荐
已为社区贡献2条内容
所有评论(0)