|
Re: how to run any sql script from the shell prompt without going to SQLPLUS. [message #156943 is a reply to message #156923] |
Mon, 30 January 2006 04:29 |
orausern
Messages: 826 Registered: December 2005
|
Senior Member |
|
|
Hi,
For one such example, see the script get_stats.sh:
#!/usr/bin/ksh
ORACLE_BASE=/oracle export ORACLE_BASE
ORACLE_HOME=/oracle/product/8.1.7 export ORACLE_HOME
ORACLE_SID=DEVAPP1 export ORACLE_SID
/oracle/product/8.1.7/bin/sqlplus -s / << EOF
set head off
set pause off
set pages 0
set feedback off
set term off
set echo off
set verify off
spool /u01/app/analyze_schema.lst
select 'exec dbms_utility.analyze_schema('||''''||username||''''||','||'''COMPUTE'''||');'
FROM DBA_USERS
where username not in ('SYSTEM','SYS');
spool off
start /u01/app/analyze_schema.lst
exit
EOF
all u need to do is to run the script from shell prompt..basically sqlplus -s runs the sqlplus in silent mode..
Upd-Mod: Add code tags.
[Updated on: Mon, 30 January 2006 16:42] by Moderator Report message to a moderator
|
|
|
|
|
Re: how to run any sql script from the shell prompt without going to SQLPLUS. [message #163791 is a reply to message #156923] |
Mon, 20 March 2006 00:38 |
sagar007
Messages: 6 Registered: March 2006
|
Junior Member |
|
|
hi.............
I am writing a small shell script...just for test...okay
all these has to be done in UNIX/LINUX
(1.)first create .sql file...let it is x_test.sql and has the contents ...
create table x_test(x1 varchar2(20),x2 number(4),x3 date)
/
exit;
(2.) write a shell script...like x_test.sh in vi editor
Here login is scott/itger@sid, or apps/apps@sid or whatever you know valid schema
echo enter the login
read login
sqlplus -s $login @x_test
(3.)run the script
$ sh x_test.sh
it will create the table in your particular schema.
[Updated on: Mon, 20 March 2006 00:39] Report message to a moderator
|
|
|