LINUX下使用指令碼直接執行SQLPLUS命令(root使用者下)

germany006發表於2013-07-10
root使用者執行以下指令碼
#!/bin/bash
su - oracle -c "sqlplus / as sysdba <
select * from tab;
exit
EOF" > /home/oracle/111.txt  2>&1


開機自啟動ORACLE
vi /home/oracle/start_db.sh

#!/bin/bash
su - oracle <
lsnrctl start
sqlplus / as sysdba
spool /home/oracle/start.log
startup
spool off
exit
EO


vi /etc/rc.local
sh /home/oracle/start_db.sh





測試:
在oracle使用者下
sqlplus -s scott/tiger@oracle < SELECT TABLESPACE_NAME,
TABLESPACE_SIZE/1024/1024/1024 as "TABLESPACE_SIZE(G)",
ALLOCATED_SPACE/1024/1024/1024  as "ALLOCATED_SPACE (G)",
FREE_SPACE/1024/1024/1024 as "FREE_SPACE(G)"
 from DBA_TEMP_FREE_SPACE
exit
EOF>>  /home/oracle/TEMP_FREE_SPACE_CHECK.txt

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28371090/viewspace-765949/,如需轉載,請註明出處,否則將追究法律責任。

相關文章