execute immediate 'create table tbname(...........)';

解决方案 »

  1.   

    create or replace function test return varchar2 as
        v_cursor number;
        v_string varchar2(200);
        v_row number;
    begin
        v_cursor:=dbms_sql.open_cursor;
        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 ('成功执行'||v_row);
        exception
            when others then
                dbms_sql.close_cursor(v_cursor);
                return ('执行失败!'||sqlcode||sqlerrm);
                raise;
    end;
      

  2.   

    execute immediate + SQL语句
      

  3.   

    当然可以呀
    create or replace aaa
    is
    beginsql = 'create table sss
          (
           aaa    char(10),
           bbb    char(10)
           )'
    EXECUTE IMMEDIATE sql;end aaa
      

  4.   

    ha ha create or replace procedure/function aaa
    is
    beginsql = 'create table sss
          (
           aaa    char(10),
           bbb    char(10)
           )'
    EXECUTE IMMEDIATE sql;end aaa