unix_oracle
unix_oracle
1
Basic networking
Two more commands you hardly will get around without when there is a need to network
troubleshooting.
$ ping <hostname>
$ tracert <hostname> (tracert in Micro$oft dialect)
Just ping and traceroute alone will provide you enough information to pinpoint the problem and
be a good friend to your system administrator.
LISTENER provides
access to database
running on the same
machine. A client and server
can run different
operating systems.
TNSNAMES.ORA file
controls to which
Oracle server(s) a
client can connect.
# .bash_profile
Connected to:
Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
SQL>
Connected to:
Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
SQL>
SQL>
You can enter OS commands
SQL> host date without leaving Oracle
Wed Mar 14 04:17:35 EST 2001
SQL> host pwd
/usr/test
SQL> host whoami
test
SQL>
Under MS-DOS
SQL> host ls
Desktop cre_customer.sql host
SQL> @cre_customer
drop table customer
*
ERROR at line 1:
ORA-00942: table or view does not exist
Table created.
Connected to:
Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
With the Partitioning option
JServer Release 8.1.6.0.0 - Production
Table dropped.
Table created.
TABLE_NAME
------------------------------
BONUS
CUSTOMER
DEPT
DUMMY
EMP
SALGRADE
6 rows selected.
SQL> select table_name from user_tables; Check what demodrop.sql script did
TABLE_NAME
------------------------------
CUSTOMER Save this in a file:
cre_customer_seq.sql
SQL> create sequence customerid start with 1 increment by 1;
commit;
© New Age Training, Inc. 13
SQL> @ins_customer
1 row created.
1 row created.
1 row created.
Commit complete.
SET PAGESIZE 20
SET LINESIZE 80
spool customer.rpt
select cust_id,
cust_name,
to_char(dob,'mm-dd-yyyy') dob,
substr(to_char(ssn),1,3)||'-'||
substr(to_char(ssn),4,2)||'-'||
substr(to_char(ssn),6,3) ssn
from customer
order by 2;
spool off
Customer Report
===============
Customer Customer
Id Name DOB SSN
-------- ------------------------------ ---------- -----------
4 Mark Paris 02-17-1940 987-65-432
5 Sam Woo 07-24-1973 999-99-999
3 Sara Davis 10-12-1965 123-45-678
- CONFIDENTIAL –
Customer Report
===============
Customer Customer
Id Name DOB SSN
-------- ------------------------------ ---------- -----------
4 Mark Paris 02-17-1940 987-65-432
5 Sam Woo 07-24-1973 999-99-999
3 Sara Davis 10-12-1965 123-45-678
- CONFIDENTIAL -
#!/bin/sh
# cre_customer.sh
# Multi task script
# date: 03-10-2001
#
sqlplus test/test << EOF
@cre_customer.sql
@cre_customer_seq.sql
@ins_customer.sql
@customer_report.sql
exit
#!/bin/sh
# cre_customer2.sh
#
# date: 03-10-2001
#
sqlplus $1/$2 << EOF
@cre_customer.sql
@cre_customer_seq.sql
@ins_customer.sql
@customer_report.sql
exit
* * * * * . cre_customer_cron.sh
$ crontab -l
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.2077 installed on Fri Apr 6 04:23:11 2001)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
* * * * . cre_customer_cron.sh
#!/bin/sh
# cre_customer_cron.sh
#
# date: 04-05-2001
#
ORACLE_HOME=/u02/oracle/817; export ORACLE_HOME;
ORACLE_SID=bigora; export ORACLE_SID;
0-59/2 * * * * ./cre_customer_cron.sh
@cre_customer.sql
@cre_customer_seq.sql
@ins_customer.sql
@customer_report.sql
exit
$ crontab -r
2. Login to your Oracle account (should be the same as under NT) and run
/u02/oracle/817/sqlplus/demo/demobld (without exiting from Oracle).
4. Write a SQL script report based on the output below (using EMP and DEPT tables).
Store output in employee.rpt file.
Employee Information
5. Using Unix command list content of the employee.rpt file. Do not use editor.