Finally figured out a problem. Linux creates timed tasks and executes SQL on a timed basis, which is divided into two case.
CASE1 SQL statements are small, so write SQL statements directly in the shell script. As follows:
[Email protected] scripts]$Cat add_data.sh
#!/bin/bash
oracle_base=/u01/app/oracle; export Oracle_base
oracle_home= $ORACLE _base/product/11.2.0/db_1; export Oracle_home
oracle_sid=prod; export Oracle_sid
oracle_unqname=prod; export Oracle_unqname
oracle_term=xterm; export Oracle_term
oracle_hostname=ora11g; export Oracle_hostname
path=/usr/sbin: $PATH; export PATH
path= $ORACLE _home/bin: $PATH; export PATH
sqlplus test/test <<eof
Spool/home/oracle/scripts/add_data.log Append--Add spool here in order to take the specific operation of SQL, left as a log
INSERT into test values (sysdate);
commit;
Spool off
exit;
Case2 SQL scripts and then writes SQL scripts in shell scripts. As follows:
[Email protected] scripts]$ cat add_data02.sh
#!/bin/bash
Oracle_base=/u01/app/oracle; Export Oracle_base
Oracle_home= $ORACLE _base/product/11.2.0/db_1; Export Oracle_home
Oracle_sid=prod; Export Oracle_sid
Oracle_unqname=prod; Export Oracle_unqname
Oracle_term=xterm; Export Oracle_term
oracle_hostname=ora11g; Export Oracle_hostname
Path=/usr/sbin: $PATH; Export PATH
Path= $ORACLE _home/bin: $PATH; Export PATH
Sqlplus test/test <<eof
Spool/home/oracle/scripts/add_data02.log Append
@/home/oracle/scripts/add_data.sql---Here add_data.sql is the SQL script to execute
Spool off
Exit
The SQL Script Add_data.sql is as follows:
[Email protected] scripts]$ cat Add_data.sql
INSERT into test values (sysdate+1);
Commit
Linux creates timed tasks and executes SQL at timed intervals