Reading data from multiple tables from Oracle DB


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading data from multiple tables from Oracle DB
# 1  
Old 02-27-2009
Question Reading data from multiple tables from Oracle DB

Hi ,

I want to read the data from 9 tables in oracle DB into 9 different files in the same connection instance (session). I am able to get data from one table to one file with below code :

X=`sqlplus -s user/pwd@DB <<eof
select col1 from table1;
EXIT;
eof`
echo $X>myfile

Can anyone suggest how the code can be modified to read multiple tables?
# 2  
Old 02-27-2009
Code:
sqlplus -s user/pwd@DB <<eof
spool file1.txt
select col1 from table1;
spool file2.txt
select col2 from table2;
spool file3.txt
select col3 from table3;
:
:
spool file9.txt
select col9 from table9;
spool off
EXIT;
eof

# 3  
Old 02-27-2009
Thanks !! Its working :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Export Oracle multiple tables to multiple csv files using UNIX shell scripting

Hello All, just wanted to export multiple tables from oracle sql using unix shell script to csv file and the below code is exporting only the first table. Can you please suggest why? or any better idea? export FILE="/abc/autom/file/geo_JOB.csv" Export= `sqlplus -s dev01/password@dEV3... (16 Replies)
Discussion started by: Hope
16 Replies

2. UNIX for Advanced & Expert Users

Identify tables from Oracle sql scripts

Hi, Please let me know if you have any thoughts on how to read a table that has all the oracle sql files or shell scripts at the job and step level to identify all the tables that does merge, update, delete, insert, create, truncate, alter table (ALTER TABLE XYZ RENAME TO ABC) and call them out... (1 Reply)
Discussion started by: techmoris
1 Replies

3. UNIX for Beginners Questions & Answers

Using bash script : How to Import data from a dsv file into multiple tables in mysql

HI I have a dsv file that looks like: <<BOF>> record_number|id_number|first name|last name|msisdn|network|points|card number|gender 312|9101011234011|Test Junior|Smith|071 123 4321|MTN|73|1241551413214444|M 313|9012023213011|Bob|Smith|27743334321|Vodacom|3|1231233232323244|M... (4 Replies)
Discussion started by: tera
4 Replies

4. Shell Programming and Scripting

Append data by looking up 2 tables for multiple files

I want to lookup values from two different tables based on common columns and append. The trick is the column to be looked up is not fixed and varies , so it has to be detected from the header. How can I achieve this at once, for multiple data files, but lookup tables fixed. The two lookup... (5 Replies)
Discussion started by: ritakadm
5 Replies

5. Programming

Oracle 10g tables dumps

HI All, I am using Oracle 10g . Want to take dumps(.dmp log) from many tables with where clause having same schema. ex : TB_MTH_ORA_CAB "WHERE TRUNC(dw_entry_dt )= TO_DATE('01-JAN-2011')" TB_AM_AT_OSS_MAT "WHERE TRUNC(dw_entry_date )>= TO_DATE('01-JAN-2011') AND TRUNC(dw_entry_date )<=... (4 Replies)
Discussion started by: Perlbaby
4 Replies

6. Web Development

mysql query for multiple columns from multiple tables in a DB

Say I have two tables like below.. status HId sName dName StartTime EndTime 1 E E 9:10 10:10 2 E F 9:15 10:15 3 G H 9:17 10:00 logic Id devName capacity free Line 1 E 123 34 1 2 E 345 ... (3 Replies)
Discussion started by: ilan
3 Replies

7. UNIX for Dummies Questions & Answers

Reading and writing data to and from multiple files

Hi, I have several text files. One main file contains the detail data, other have some information to extract data from the main file, and some are empty files. Examples are shown below: The main file look like: MainFile.txt >Header1 data1...data1... >Header2 data2...data2... ... ...... (2 Replies)
Discussion started by: Fahmida
2 Replies

8. Shell Programming and Scripting

Script not reading Data from oracle table properly

Hi, I have a case where i am connecting to the oracle DB and reading a column value.... Script is in production...it was running fine,,,but suddenly now some times its started giving pain.... Script runs dailly....but sometimes its reading data from Oracle DB and sometimes its not rading the... (2 Replies)
Discussion started by: Sagarddd
2 Replies

9. Shell Programming and Scripting

Converting tables of row data into columns of tables

I am trying to transpose tables listed in the format into format. Any help would be greatly appreciated. Input: test_data_1 1 2 90% 4 3 91% 5 4 90% 6 5 90% 9 6 90% test_data_2 3 5 92% 5 4 92% 7 3 93% 9 2 92% 1 1 92% ... Output:... (7 Replies)
Discussion started by: justthisguy
7 Replies

10. Programming

mmap vs shared memory - which is faster for reading data between multiple process

Between mmap and shared memory which is the best method of sharing data between multiple applications, interms of speed? (1 Reply)
Discussion started by: nmds
1 Replies
Login or Register to Ask a Question