oracle在能不能在sql plus之类的地方导出数据?我需要到处到一个文件中,以csv的形式。类似于export to  C:\1.csv    select * from table_A
有没有呢?

解决方案 »

  1.   

    如果记录不太多的话,可以借助 plsqldev   可以拷贝出excel格式的
      

  2.   

    --这个脚本就行了(你也可以保存为一个c:\test.sql,然后在sqlplus下:@c:\test.sql)
    set heading off
    set termout off
    set feedback off
    set pagesize 0
    set trimsout on
    set trimspool on
    spool sr.csv
    select t.srtypeid||','||to_char(t.accepttime,'yyyy-mm-dd hh24:mi:ss')||','||t.subsnumber||','||t.calledno from t_sr_servicerequest t where t.serviceid between '080225' and '080301';
    spool off
    set heading off
    set termout off
    set feedback off
    set pagesize 0
    set trimsout on
    set trimspool on
    spool test.csv
    select col_a||','||to_char(t.mydate,'yyyy-mm-dd hh24:mi:ss')||','||t.col_b from t_sr_servicerequest t where t.mydate between '080225' and '080301';
    spool off
      

  3.   

    不好意思,上面复制了两份
    --这个脚本就行了(你也可以保存为一个c:\test.sql,然后在sqlplus下:@c:\test.sql)
    spool off
    set heading off
    set termout off
    set feedback off
    set pagesize 0
    set trimsout on
    set trimspool on
    spool test.csv
    select col_a||','||to_char(t.mydate,'yyyy-mm-dd hh24:mi:ss')||','||t.col_b 
            from your_table t where t.mydate between '080225' and '080301';
    spool off
      

  4.   


    spool C:\1.csvselect * from table_Aspool off
      

  5.   


    if mycursor%found then outyanzheng:=1;   
    mycursor%found=true 这样都可以SQL> ed
    已写入 file afiedt.buf  1  declare
      2  v_COL1 number;
      3  cursor c1 is select COL1 from test1;
      4  num number:=0;
      5  begin
      6  open c1;
      7  fetch c1 into v_COL1;
      8  if c1%found=true then
      9  num:=1;
     10  end if;
     11  dbms_output.put_line(num);
     12* end;
    SQL> /
    1PL/SQL 过程已成功完成。
    SQL> ed
    已写入 file afiedt.buf  1  declare
      2  v_COL1 number;
      3  cursor c1 is select COL1 from test1;
      4  num number:=0;
      5  begin
      6  open c1;
      7  fetch c1 into v_COL1;
      8  if c1%found then
      9  num:=1;
     10  end if;
     11  dbms_output.put_line(num);
     12* end;
    SQL> /
    1PL/SQL 过程已成功完成。
      

  6.   


    他返回不是 true or false两个值