str :='truncate table tab_name';
execute immediate str;

解决方案 »

  1.   

    两种方式:
    1、execute immediate 'truncate table your_tablename'
    2、使用包
      dbms_utility.exec_ddl_statement('truncate table your_tablename');
      

  2.   

    你可以先将你要TRUNCATE的表锁定
    Lock Table your_tablename in Exclusive Mode
    然后在执行TRUNCATE
    execute immediate 'truncate table your_tablename'
      

  3.   

    sqlcmd :='truncate table tab_name';
    execute immediate sqlcmd;
    要注意使用这条命令,因为它是没有办法回滚的
      

  4.   

    要注意一点:
    当前用户要有drop any table权限
    grant drop any table to new_user;