Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Export Oracle multiple tables to multiple csv files using UNIX shell scripting Post 303043789 by Hope on Thursday 6th of February 2020 09:02:00 PM
Old 02-06-2020
Here is another try, Any body who can make this more efficient? I don't want to use the setting and the sql connection more than once.
Thanks ,
Hope



Code:
FIle = "geo_JOB.csv"

sqlplus -s dev01/password@dEV3 <<EOF

SET HEADING ON
SET WRAP OFF
SET TRIMSPOOL ON
SET TRIMOUT ON
SET PAGESIZE 50000
SET COLSEP ","
SET LINESIZE 500
SET NEWPAGE NONE
SET FEEDBACK OFF
SET VERIFY OFF
SET UNDERLINE OFF

SPOOL $FILE

SELECT * FROM geo_JOB ;

SPOOL OFF
EXIT
EOF


FIle = "geo_JOB2.csv"

sqlplus -s dev01/password@dEV3 <<EOF

SET HEADING ON
SET WRAP OFF
SET TRIMSPOOL ON
SET TRIMOUT ON
SET PAGESIZE 50000
SET COLSEP ","
SET LINESIZE 500
SET NEWPAGE NONE
SET FEEDBACK OFF
SET VERIFY OFF
SET UNDERLINE OFF

SPOOL $FILE

SELECT * FROM geo_JOB2 ;

SPOOL OFF
EXIT
EOF

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

2. Shell Programming and Scripting

Add multiple .csv files as sheets to an excel file in unix.

Hi, I am using Solaris 8. My script outputs 4 .csv files. Currently I am SFTPing the files and creating a new excel file with the 4 files as sheets. Can anyone suggest ways to do this in UNIX ? Thanks, David. (2 Replies)
Discussion started by: libin4u2000
2 Replies

3. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: net
2 Replies

4. Shell Programming and Scripting

How to process multiple input files using Shell scripting

Hi, I would like to write a for loop that does the following: I have a file called X.txt and other files called 1.txt,2.txt, .....,1000.txt. I want to substitute the 6th column of the file X.txt with 1.txt and store the output as X.1. Then I want to do the same with X.txt and 2.txt and store... (0 Replies)
Discussion started by: evelibertine
0 Replies

5. Shell Programming and Scripting

How to run multiple functions in Background in UNIX Shell Scripting?

Hi, I am using ksh , i have requirement to run 4 functions in background , 4 functions call are available in a case that case is also in function, i need to execute 1st function it should run in background and return to case and next i will call 2nd function it should run in background and... (8 Replies)
Discussion started by: karthikram
8 Replies

6. Shell Programming and Scripting

Assigning multiple column's value from Oracle query to multiple variables in UNIX

Hi All, I need to read values of 10 columns from oracle query and assign the same to 10 unix variables. The query will return only one record(row). I tried to append all these columns using a delimiter(;) in the select query and assign the same to a single variable(V) in unix. I thought I... (3 Replies)
Discussion started by: hkrishnan91
3 Replies

7. Shell Programming and Scripting

Finding total distinct count from multiple csv files through UNIX script

Hi All , I have multiple pipe delimited csv files are present in a directory.I need to find out distinct count on a column on those files and need the total distinct count on all files. We can't merge all the files here as file size are huge in millions.I have tried in below way for each... (9 Replies)
Discussion started by: STCET22
9 Replies

8. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

9. Shell Programming and Scripting

Shell Scripting - Select multiple files from numbered list

I am trying to have the user select two files from a numbered list which will eventually be turned into a variable then combined. This is probably something simple and stupid that I am doing. clear echo "Please Select the Show interface status file" select FILE1 in *; echo "Please Select the... (3 Replies)
Discussion started by: dis0wned
3 Replies

10. UNIX for Beginners Questions & Answers

How to read multiple files at same time through UNIX scripting?

How to read multiple files at simultaneously? (1 Reply)
Discussion started by: Priyanka_M
1 Replies
MYSQLMETAGREP(1)						  MySQL Utilities						  MYSQLMETAGREP(1)

NAME
mysqlmetagrep - Search MySQL servers for objects matching a pattern SYNOPSIS
mysqlmetagrep [options] [pattern | server] ... DESCRIPTION
This utility searches for objects matching a given pattern on all the servers specified using instances of the --server option. It produces output that displays the matching objects. By default, the first nonoption argument is taken to be the pattern unless the --pattern option is given. If the --pattern option is given, all nonoption arguments are treated as connection specifications. Internally, the utility generates an SQL statement for searching the necessary tables in the INFORMATION_SCHEMA database on the designated servers and executes it in turn before collecting the result and printing it as a table. Use the --sql option to have the utility display the statement rather than execute it. This can be useful if you want to feed the output of the statement to another application such as the mysql monitor. The MySQL server supports two forms of patterns when matching strings: SQL Simple Patterns (used with the LIKE operator) and POSIX Regular Expressions (used with the REGEXP operator). By default, the utility uses the LIKE operator to match the name (and optionally, the body) of objects. To use the REGEXP operator instead, use the --regexp option. Note that since the REGEXP operator does substring searching, it is necessary to anchor the expression to the beginning of the string if you want to match the beginning of the string. To specify how to display output, use one of the following values with the --format option: grid (default) Display output in grid or table format like that of the mysql monitor. csv Display output in comma-separated values format. tab Display output in tab-separated format. vertical Display output in single-column format like that of the G command for the mysql monitor. SQL Simple Patterns The simple patterns defined by the SQL standard consist of a string of characters with two characters that have special meaning: % (per- cent) matches zero or more characters and _ (underscore) matches exactly one character. For example: 'mats%' Match any string that starts with 'mats'. '%kindahl%' Match any string containing the word 'kindahl'. '%_' Match any string consisting of one or more characters. POSIX Regular Expressions POSIX regular expressions are more powerful than the simple patterns defined in the SQL standard. A regular expression is a string of char- acters, optionally containing characters with special meaning: . Match any character. ^ Match the beginning of a string. $ Match the end of a string. [axy] Match a, x, or y. [a-f] Match any character in the range a to f (that is, a, b, c, d, e, or f). [^axy] Match any character except a, x, or y. a* Match a sequence of zero or more a. a+ Match a sequence of one or more a. a? Match zero or one a. ab|cd Match ab or cd. a{5} Match five instances of a. a{2,5} Match from two to five instances of a. (abc)+ Match one or more repetitions of abc. This is but a brief set of examples of regular expressions. The full syntax is described in the MySQL manual, but can often be found in regex(7). OPTIONS
mysqlmetagrep accepts the following command-line options: --help Display a help message and exit. --body, -b Search the body of stored programs (procedures, functions, triggers, and events). The default is to match only the name. --database=<pattern> Look only in databases matching this pattern. --format=<format>, -f<format> Specify the output display format. Permitted format values are grid, csv, tab, and vertical. The default is grid. --object-types=<types>, --search-objects=<types> Search only the object types named in types, which is a comma-separated list of one or more of the values procedure, function, event, trigger, table, and database. The default is to search in objects of all types. --pattern=<pattern>, -e=<pattern> The pattern to use when matching. This is required when the first nonoption argument looks like a connection specification rather than a pattern. If the --pattern option is given, the first nonoption argument is treated as a connection specifier, not as a pattern. --regexp, --basic-regexp, -G Perform pattern matches using the REGEXP operator. The default is to use LIKE for matching. This affects the --database and --pattern options. --server=<source> Connection information for a server to search in <user>[:<passwd>]@<host>[:<port>][:<socket>] format. Use this option multiple times to search multiple servers. --sql, --print-sql, -p Print rather than executing the SQL code that would be executed to find all matching objects. This can be useful to save the state- ment for later execution or to use it as input for other programs. --version Display version information and exit. NOTES
For the --format option, the permitted values are not case sensitive. In addition, values may be specified as any unambiguous prefix of a valid value. For example, --format=g specifies the grid format. An error occurs if a prefix matches more than one valid value. EXAMPLES
Find all objects with a name that matches the pattern 't_' (the letter t followed by any single character): $ mysqlmetagrep --pattern="t_" --server=mats@localhost +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | mats:*@localhost:3306 | TABLE | t1 | test | | mats:*@localhost:3306 | TABLE | t2 | test | | mats:*@localhost:3306 | TABLE | t3 | test | +------------------------+--------------+--------------+-----------+ To find all object that contain 't2' in the name or the body (for routines, triggers, and events): $ mysqlmetagrep -b --pattern="%t2%" --server=mats@localhost:3306 +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | root:*@localhost:3306 | TRIGGER | tr_foo | test | | root:*@localhost:3306 | TABLE | t2 | test | +------------------------+--------------+--------------+-----------+ In the preceding output, the trigger name does not match the pattern, but is displayed because its body does. This is the same as the previous example, but using the REGEXP operator. Note that in the pattern it is not necessary to add wildcards before or after t2: $ mysqlmetagrep -Gb --pattern="t2" --server=mats@localhost +------------------------+--------------+--------------+-----------+ | Connection | Object Type | Object Name | Database | +------------------------+--------------+--------------+-----------+ | root:*@localhost:3306 | TRIGGER | tr_foo | test | | root:*@localhost:3306 | TABLE | t2 | test | +------------------------+--------------+--------------+-----------+ COPYRIGHT
Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA AUTHOR
MySQL Utilities Team COPYRIGHT
2010, Oracle and/or its affiliates. All rights reserved. 1.0.3 May 09, 2012 MYSQLMETAGREP(1)
All times are GMT -4. The time now is 12:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy