Store table contents in csv file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Store table contents in csv file
# 1  
Old 08-02-2010
Store table contents in csv file

I need to write a script to store the contents of a table in a csv file
I'm using Toad, it's a Oracle database.
# 2  
Old 08-02-2010
Toad can do that for you.
Select schema browser view ==> Right click on table ==> Save as...

Is this enough?
# 3  
Old 08-02-2010
If you are using Toad, then at the left extreme top of your results window, right click, choose Save as -> choose XLS as file format and "," as delimiter.
# 4  
Old 08-02-2010
I actually need to have it in a script, the reason is because I want to do some automated testing, so I'm working with many files etc at a time, I want one script that will make the process faster.
# 5  
Old 08-02-2010
If you want it scripted, use SQL*Plus on the command line, instead of Toad, and run a script like this:
Code:
sqlplus -s user/pw@sid << EOD
set colsep ,
set head off
set trimspool
spool /path/to/file.csv
select * from table;
spool off
EOD

# 6  
Old 08-02-2010
Thank you for all you help, one more request please, is it possible to have this in a bash script

---------- Post updated at 07:39 AM ---------- Previous update was at 07:35 AM ----------

I was looking at something along this lines:
Code:
#!/bin/bash
sqlstr = <<-'SQL'
select * from celltable > importcell.csv
SQL

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trying To Write File Contents To Specfic .csv Cell

Hi, I'm attempting to write the entire contents of a file to a specific .csv cell. So far have only a nawk one liner that will write a value into a specific .csv cell. Trying to use man page but can't seem to get any farther. Any help would be appreciated. nawk -v r=2 -v c=3 -v val=5 -F,... (7 Replies)
Discussion started by: jimmyf
7 Replies

2. Shell Programming and Scripting

Update the table using values from a csv file

i want to run update query for oracle which is in up.sql taking values from a.csv. I have implemented shell script to do it. extn="perl" ls -1 | while read file do echo "$file,$extn" > a.csv done up.sql contains update file_list set filename=$1 where extn=$2; The code to update is... (2 Replies)
Discussion started by: millan
2 Replies

3. Shell Programming and Scripting

Place the contents of a .CSV file to an array

Hi, I am trying to place the contents of a .CSV file to an array, but not sure how to do that. Here is my .CSV file content: App,SLA,Job name,Avg start time,Avg run time,Frequency,Downstream apps XYZ,,ABC14345,3:00 AM,00.04.00,Daily,STAMP XYZ,9:00,ABC12345,3:15 AM,00.05.00,Daily,STAMP ... (4 Replies)
Discussion started by: ajayakunuri
4 Replies

4. Shell Programming and Scripting

Convert file in csv or table

Hi there, i have a file like that in attachment (PLEVA3_280711_SAP.txt), i would extract some basic information from it and report in a new file or table like this: i try to use bash and i extract the single object in this way (see attach scriptino.sh), but i receive a strange... (5 Replies)
Discussion started by: alen192
5 Replies

5. Shell Programming and Scripting

Read the contents of a file and store them in a variable

Hi Gurus, I am trying for a scenario where in I want to read the contents of a file line by line and then store them in variables. Below is the script: #!/bin/ksh while read line do id=`echo $line | cut -f1 -d |` name=`echo $line | cut -f2 -d |` echo $id ... (11 Replies)
Discussion started by: svajhala
11 Replies

6. UNIX for Dummies Questions & Answers

Storing data from a table into a csv file

Hi I need to write a bash script to take the data stored in 3 oracle tables .. and filter them and store the results in a csv file. It is an Oracle database Thank you (1 Reply)
Discussion started by: ladyAnne
1 Replies

7. UNIX and Linux Applications

Does anybody know how to store my tables to a csv file?

Hi I'm using an oracle database... Lets call it databasename My username and password are the same .... lets all that andrea/andrea So I want to write a script to copy all the data from my table called tablename and store that data to a csv file called filename. I cant seem to get... (2 Replies)
Discussion started by: ladyAnne
2 Replies

8. Shell Programming and Scripting

Most reliable way to store file contents in an array in bash

Hi Guys, I have a file which has numbers in it separated by newlines as follows: 1.113 1.456 0.556 0.021 -0.541 -0.444 I am using the following code to store these in an array in bash: FILE14=data.txt ARRAY14=(`awk '{print}' $FILE14`) (6 Replies)
Discussion started by: npatwardhan
6 Replies

9. Shell Programming and Scripting

store the table data in excel file

Hello - I have a below table and i want to extract the data into excel sheet and send to different location. Here is the table structure... SQL> desc t_i1_exportdocs Name Null? Type ----------------------------------------- --------... (11 Replies)
Discussion started by: govindts
11 Replies

10. Shell Programming and Scripting

Shell script for converting file contents into CSV

Hi, I am new in unix, I just want to replace some values from text file according to column numbers. Like, I am having a table as given below: val1 val2 val3 val4 val5 val6 val7 val8 val9 val10 val11 val12 val13 Now i want... (5 Replies)
Discussion started by: rish_max
5 Replies
Login or Register to Ask a Question