Home > database >  extract data in csv from table with 2 billion records
extract data in csv from table with 2 billion records

Time:01-26

Wanted to know the tool which can extract data in csv from a table or by executing a sql query like

select * from table 1 inner join table 2 on ...

Data is currently in oracle database and required to be extracted in csv and processed through Java code and after processing final csv/multiple csv files required to be loaded back to same oracle database .

Is there any tool script does this task efficiently

CodePudding user response:

I think this is a very bad idea. Anyway, you can use the ODBC Driver "Microsoft Text Driver (*.txt; *.csv)" which should be available on each Windows.

Setup the connection in ODBC Administrator odbcad32.exe

enter image description here

enter image description here

And then you can select the data with any generic ODBC capable SQL tool, e.g. enter image description here

  1. To export a table data to a .csv file, run the command below, but adjust the values:

bcp <database_name>.<schema_name>.<table_name> out <file_destination_path> -S<server_instance> -c -t"," -T

CodePudding user response:

Using SQLcl: SQLcl is a free tool provided by Oracle.

Connect to the database you want to export

To guarantee a proper export of your data, you have to change some of the system variables of SQLcl: o SET SQLFORMAT csv (automatic conversion into proper csv) o SET TERMOUT OFF (suppresses output on display - this option is only necessary when using scripts) o SET FEEDBACK OFF (suppresses displaying the number of records returned by a query)

To apply each option, just press ENTER after every single command Note: These options have to be set every time SQLcl is started!

Use the integrated spooler with the appended file path to start the process

SQLcl will write the result set of your SELECT-statement to table1.csv

To finish the process, you have to stop the spooler by using the command: spool off

  • Related