sqlplus id/pwd SQL> select * from table 했을때 결과를 텍스트파일로 받게 하여 쉘에서 스크립트로 실행해주고 싶은데 가능한가요?
ps) 오라클 q & a 전문 사이트를 알려주시면 감사하겠습니다.
SQL> set head off SQL> spool result.txt SQL> select empno, ename from emp where rownum <= 5; 7369 SMITH 7499 ALLEN 7521 WARD 7566 JONES 7654 MARTIN SQL> spool off; SQL> !cat result.txt SQL> select empno, ename from emp where rownum <= 5; 7369 SMITH 7499 ALLEN 7521 WARD 7566 JONES 7654 MARTIN SQL> spool off; SQL>
7369 SMITH 7499 ALLEN 7521 WARD 7566 JONES 7654 MARTIN
SQL> spool off; SQL> !cat result.txt SQL> select empno, ename from emp where rownum <= 5;
SQL> spool off;
SQL>
-------------------------- Donghyun Jung
위의 결과를 쉘에서 쉘스크립트로 작성한가 말이죠. 자동화시켜려 하거든요.
cat > ora.sh sqlplus id/pwd ...
^D
이렇게 해서 chmod u+x ora.sh
ora.sh (엔터) 이렇게 하고싶거든요^^
foo.sh
#!/bin/sh #Define Env for ORACLE export ORACLE_BASE=/oradbm1/app/oracle; export ORACLE_HOME=$ORACLE_BASE/product/8.0.5; export ORACLE_SID=TMN; export NLS_LANG=AMERICAN_AMERICA.KO16KSC5601; export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib/pa20_64:/usr/lib; export SHLLIB_PATH=$ORACLE_HOME/lib:/usr/lib/pa20_64:/usr/lib; export TNS_ADMIN=$ORACLE_HOME/network/admin; export PATH=.:$ORACLE_HOME/bin:/usr/bin:/usr/local:$PATH; #Define Program Variables SQLLDR=/oradbm1/app/oracle/product/8.0.5/bin/sqlldr SQLPLUS=/oradbm1/app/oracle/product/8.0.5/bin/sqlplus sqlplus -s 2gcms/2gcms123 @/disk7/foo.sql > foo.txt
foo.sql
set heading off set verify off select * from tab; quit;
Think..
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
[quote="sqlplus"]SQL> set head offS
--------------------------
Donghyun Jung
감사합니다만.
위의 결과를 쉘에서 쉘스크립트로 작성한가 말이죠.
자동화시켜려 하거든요.
cat > ora.sh
sqlplus id/pwd
...
^D
이렇게 해서 chmod u+x ora.sh
ora.sh (엔터)
이렇게 하고싶거든요^^
foo.sh[code:1]#!/bin/sh#Define
foo.sh
foo.sql
Think..
댓글 달기