spool c:\aaa.txt
select * from yourtable;
spool off

解决方案 »

  1.   

    To create a flat file with SQL*Plus, you first must enter the following SET commands: SET NEWPAGE 0
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET HEADING OFF
    SET MARKUP HTML OFF SPOOL OFF
    After entering these commands, you use the SPOOL command as shown in the previous section to create the flat file. 
      

  2.   

    請問在procedure里可以用這個spool嗎,我試了,似乎不行.那麼有沒有其他函數可以呢.
      

  3.   

    procedure中可以把查询数据格式化写到文件里面
      

  4.   

    例子
    SQL> spool off;
    SQL> spool c:\test.txt;
    SQL> select code from comm_codeinfo where type='INBOUND';CODE
    ----------------------------------------
    INBOUND-8
    INBOUND-3
    INBOUND-4
    INBOUND-5
    INBOUND-6
    INBOUND-7
    INBOUND-99
    INBOUND-1
    INBOUND-2已选择9行。SQL> SPOOL OFF;现在你可以查看c:\test.txt文件了。