millan
1
I want to connect to oracle database from solaris...
After that i will drop and create a no.of tables.One of the table example is as below.
sqlplus -s usrname/password@dbname << SQL >> $logfile 2>&1
echo " dropping the table1" | tee logfile
DROP TABLE Table1
echo "creating the table1" | tee logfile
CREATE TABLE table1
(
VERSION VARCHAR2(25 BYTE),
CATEGORY VARCHAR2(255 BYTE),
SHORT_NAME VARCHAR2(25 BYTE),
)
commit;
quit
SQL
My question is will this code print message lfor creation and deletion in the screen as well as in the log...
Please let me know if i have to modify anything in the code.
Thank you in advance.
Yoda
2
No, the code will not print messages on your screen because you are redirecting stdout and stderr to logfile:
sqlplus -s usrname/password@dbname << SQL >> $logfile 2>&1
Also below statements are wrong, because you cannot use shell built-ins, commands or utilities inside SQL block:
echo " dropping the table1" | tee logfile
DROP TABLE Table1
echo "creating the table1" | tee logfile
You should perform below modification:
sqlplus -s usrname/password@dbname << SQL | tee $logfile
prompt dropping the table1;
DROP TABLE Table1;
prompt creating the table1;
CREATE TABLE table1
(
VERSION VARCHAR2(25 BYTE),
CATEGORY VARCHAR2(255 BYTE),
SHORT_NAME VARCHAR2(25 BYTE),
);
commit;
quit
SQL