执行多个SQL语句 建立aa.sql将多个sql写里面在plus *sql 中执行@aa.sql 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 luyuen(滋味)每个语句间用什么分割符阿?好像;是不行的! declarestr varchar2(100);beginstr:='begin drop table a; create table a(ID varchar2(1)); end;';execute immediate str;end;/ 提示错误:declare*ERROR 位于第 1 行:ORA-06550: 第 1 行, 第 8 列:PLS-00103: 出现符号 "CREATE"在需要下列之一时:begin case declare exitfor goto if loop mod null pragma raise return select updatewhile with <an identifier><a double-quoted delimited-identifier> <a bind variable> <<close current delete fetch lock insert open rollbacksavepoint set sql execute commit forall merge<a single-quoted SQL string> pipe符号 "lock在 "CREATE" 继续之前已插入。ORA-06550: 第 1 行, 第 30 列:PLS-00103: 出现符号 "("在需要下列之一时:. , @ in <an identifier><a double-quoted delimited-identifier> partition subpartitionORA-06550: 第 1 行, 第 48 列:PLS-00103: 出现符号 "DROP"在需要下列之一时:begin function packagepragma procedure subtype type use <an identifier><a double-quoted delimited-identifier> form current cursorORA-06512: 在line 5 用SQL*PLUS WORKSHEET,可以很方便的调试,我不知道SQL*PLUS有啥用,还请教教我 直接复制后粘贴即可实现多条sql执行 做一个.sql的文件在里面写SQL语句在sqlplus里执行@ 路径名/文件名 SQL> declare 2 cursor t_sor is 3 select table_name from user_tables; 4 str varchar2(100); 5 begin 6 str:='begin '; 7 for v_sor in t_sor loop 8 str:=str||'begin execute immediate ''drop table '||v_sor.table_name||''';end;'; 9 end loop; 10 str:=str||' end;'; 11 execute immediate str; 12 end; 13 /PL/SQL procedure successfully completed大家明白了吗?就是在pl/sql不能直接进行ddl操作. 请教SQL语句数据库为ORACLE 请教:数据集显示方式重新排列 dbms_random.seed到底是用来干吗的啊? 发布完程序以后,进行导出操作时报错 oracle8.05如何使用,不懂,请教,在线急 ERROR:ORA-12541: TNS: 没有监听器?! 哪里有Oracle8i下载? 如何把ORACLE734的DMP导入到ORACLE805中? 请教:两台不同字符集、不同版本服务器数据转存出乱码问题 这种SQL语句怎么写 ORCL求大神 如何得到游标中的记录行数? 如何建新數據庫?
每个语句间用什么分割符阿?好像;是不行的!
str varchar2(100);
begin
str:='begin drop table a; create table a(ID varchar2(1)); end;';
execute immediate str;
end;
/
*
ERROR 位于第 1 行:
ORA-06550: 第 1 行, 第 8 列:
PLS-00103: 出现符号 "CREATE"在需要下列之一时:
begin case declare exit
for goto if loop mod null pragma raise return select update
while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge
<a single-quoted SQL string> pipe
符号 "lock在 "CREATE" 继续之前已插入。
ORA-06550: 第 1 行, 第 30 列:
PLS-00103: 出现符号 "("在需要下列之一时:
. , @ in <an identifier>
<a double-quoted delimited-identifier> partition subpartition
ORA-06550: 第 1 行, 第 48 列:
PLS-00103: 出现符号 "DROP"在需要下列之一时:
begin function package
pragma procedure subtype type use <an identifier>
<a double-quoted delimited-identifier> form current cursor
ORA-06512: 在line 5
在sqlplus里执行
@ 路径名/文件名
2 cursor t_sor is
3 select table_name from user_tables;
4 str varchar2(100);
5 begin
6 str:='begin ';
7 for v_sor in t_sor loop
8 str:=str||'begin execute immediate ''drop table '||v_sor.table_name||''';end;';
9 end loop;
10 str:=str||' end;';
11 execute immediate str;
12 end;
13 /PL/SQL procedure successfully completed大家明白了吗?就是在pl/sql不能直接进行ddl操作.