1

When I export data from SQL Developer GUI, setting format: csv, left enclosure: ", right enclosure: ", and Encoding: UTF8, I get data exactly the way that I need it for processing in Python.

However, when I attempt to do the same thing from SQL Plus, I get very different results. Here are my settings (file.sql is simply a select statement):

export ORACLE_SID=MYSID
sqlplus / as sysdba <<EOF
conn myUser/myPass 
set heading off
set termout off 
set trimout off
set newpage none
set pages 0
set feedback off
set echo off
set verify off
set trimspool on
set sqlprompt "" 
set colsep ","
set linesize 32767      
@/home/username/file.sql
exit
EOF

How can I export the data from SQL Plus so that it is exactly like that from SQL Developer? As an FYI, when I run file -i myfile.csv I get "application/octet-stream; charset=binary", while from SQL Plus the file is some form of "ASCII" (and for some tables "ISO").

migrated from stackoverflow.com May 28 '15 at 2:59

This question came from our site for professional and enthusiast programmers.

  • 2
    Because they are different commands? You can spool from SQL Developer, which would be much more similar. What exactly is different between the outputs? Just saying it is very different isn't very helpful. You haven't shown the query you're running, either, which might be relevant. – Alex Poole May 27 '15 at 22:31
  • What Alex said. HOW is it different? Also, why would you expect them to be the same, formatting-wise? Also, for what it's worth, our new SQLcl command line tool supports CSV formatting, just run your query with select /*csv*/ from ... and you're done. – thatjeffsmith May 28 '15 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy