在Oracle中对ddl语句要用动态SQL才可以的execute immediate 'creatle tabel t1(a int)';

解决方案 »

  1.   

    用动态sqlexecute immediate 'drop table zw_regcntsubscrb';
      

  2.   

    9.0以上才可以用execute immediate 
    9.0以下create or replace function test return varchar2 asv_cursor number;v_string varchar2(200);v_row number;beginv_cursor:=dbms_sql.open_cursor;--v_string:='update fnd_user a set a.description=''fred'' where a.user_id=1055';v_string:='create table testdb (text varchar2(200))';dbms_sql.parse(v_cursor,v_string,dbms_sql.native);v_row:=dbms_sql.execute(v_cursor);dbms_sql.close_cursor(v_cursor);return ('成功执行');exceptionwhen others thendbms_sql.close_cursor(v_cursor);return ('执行失败!'||sqlcode||sqlerrm);raise;end;
      

  3.   

    DDL和DML,DML包括select、insert、update、delete,其它的如drop、create等都是DDL
      

  4.   

    不同意 freddy2003() 兄的说法:
    9.0以上才可以用execute immediate 我的817库一直这么用. 
    execute immediate 'drop table...'dbms_sql是另一种执行动态SQL 的方法. 
      

  5.   

    呵呵,8i以上就可以用execute immediate了。dbms_sql包7i就有,用过得最老版本就是7i了。不知道以前的版本有没有。
      

  6.   

    8i应该就可以用execute immediate
    ddl为数据定义语言,包括create,alter,drop