How do I spool to a csv formatted file using sqlplus?



How do I spool to a csv formatted file using sqlplus?..

Answer / Amar Gupta

"To spool a CSV formatted file in SQLPLUS, use the following command: `SPOOLOFF` (to turn off spooling) and then create a new file with `SPFILE <filename> SET TERMOUT OFF`; after executing your query, you can redirect output to the created file using `SPool <filename>.csv`. For formatting CSV, use `CHR(10)` for line breaks. Here's an example:
```sqln
SPOFF;n
SPFILE myfile SET TERMOUT OFF;n
SELECT column1 || ',' || CHR(10) || column2 || ',' || CHR(10) FROM your_table;n
SPOOL myfile.csv;"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

What happens to the current transaction if a ddl statement is executed?

1 Answers  


What is analyze command used for?

1 Answers  


What is the minimum client footprint required to connect c# to an oracle database?

1 Answers  


Define 'view' advantage ?

2 Answers   AZTEC, TCS,


when a grant option is encountered for a table EMP to a peer sitting beside you who has already having the table of that name (EMP), then what is the result?

2 Answers  


What privilege is needed for a user to create views in oracle?

1 Answers  


How to get the Installed Oracle Version Information ?

1 Answers   MCN Solutions,


What are data pump export and import modes?

1 Answers  


How to calculate date and time differences in oracle?

1 Answers  


Give the sequence in which triggers fired during insert operations, when the following 3 triggers are defined at the same block level ?

1 Answers  


structural difference between bitmap and btree index ?

1 Answers   Infosys,


In Oracle Applications We are Using Sub Ledger Accounting. When we Transfer the Data all modules (AP,AR,CE,FA) to SLA We done Some customizations? What are They??

1 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1803)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)