spool c:\truncate.sql
select 'truncate table '|| table_name||'..' from ...where  table_name like '..';
spool off;
@c:\truncate.sql

解决方案 »

  1.   

    用对应的参数替换后是下面的样子吗?
    spool c:\truncate.sql
    select 'truncate table '|| table_name||'DROP STORAGE' from USER_TABLES where table_name like '%HIS%';
    spool off;
      

  2.   

    但这样会出现以下的错误:The following error has occurred:ORA-00900: invalid SQL statement
      

  3.   

    'truncate table '|| table_name||'..'
    能否再详细介绍一下这个是什么意思。
      

  4.   

    set heading off
    set feedback off
    spool c:\truncate.sql
    select 'truncate table '|| table_name||'DROP STORAGE;' from USER_TABLES where table_name like '%HIS%';
    spool off;
    @c:\truncate.sql
      

  5.   

    出现以下错误:The following error has occurred:ORA-00922: missing or invalid option
      

  6.   

    说明(像下面这样的语句是可以正常运行的):
    select * from USER_TABLES where table_name like '%HIS%';
    TRUNCATE TABLE JOB_HIS DROP STORAGE
      

  7.   

    可能是少了一个空格,再试
    :)
    set heading off
    set feedback off
    spool c:\truncate.sql
    select 'truncate table '|| table_name||' DROP STORAGE;' from USER_TABLES where table_name like '%HIS%';
    spool off;
      

  8.   

    SQL> select * from a;        AA
    ----------
    123.123456SQL> spool c:\truncate.sql
    SQL> select 'truncate table '|| table_name||' DROP STORAGE;' from USER_TABLES
      2  where table_name ='A';'TRUNCATETABLE'||TABLE_NAME||'DROPSTORAGE;'
    -----------------------------------------------------------
    truncate table A DROP STORAGE;SQL> spool off;
    SQL> @c:\truncate.sql
    SP2-0734: 未知的命令开头 "SQL> selec..." - 忽略了剩余的行。
    SP2-0734: 未知的命令开头 "'TRUNCATET..." - 忽略了剩余的行。表已截掉。SP2-0734: 未知的命令开头 "SQL> spool..." - 忽略了剩余的行。
    SQL> select * from a;未选定行SQL>