a) Create Database Link tnsname entries # tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = astra17.met.edu)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) ) ORCL16 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = astra16.met.edu)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)
) ) ORCL15 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = astra15.met.edu)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) ) Database Link Creation create public database link dblink_17 connect to system identified by password using 'orcl17' Database link created create public database link dblink_16 connect to system identified by password using 'orcl16'
b) Distributed Query Execution Table Creation create table account ( acno number(5), name varchar2(20), bid number(5),
balance number(6,2), actype varchar2(1) ) Table created create table branch ( bid varchar2(5), bname varchar2(30), location varchar2(30) ) Table created
select * from Account; ACNO 1 2 3 4 5 NAME Amit Rohit Nipun Sunny Neha BID 1 1 1 1 1 BALANCE 500 400 300 200 100 ACT s s s c c
Select * from account@dblink_16; ACNO 6 7 8 9 10 NAME Namdeo Ramdeo Devram Eknath Dev BID 2 2 2 2 2 BALANCE 7000 2000 3200 4000 5000 ACT s s s c c
13 14 15
3 3 3
c s c
Uncommited data update account set balance=1000 where acno=1 1 row updated.
update account@dblink_15 set balance=20 where acno=1 update account@dblink_15 set balance=30 where acno=1 * ERROR at line 1: ORA-02049: timeout: distributed transaction waiting for lock ORA-02063: preceding line from DBLINK_15
c) Asynchronous Replication
create table scott.sales ( oid number(3), sid number(3) primary key, pid varchar2(3), qty number(4), amt number(4), odate date ) Creation of SnapShot
Create snapshot sales PCTFREE 15 storage ( INITIAL 200k next 200k pctincrease 1000) using index refresh force start with sysdate next sysdate + (1/1440) as select * from scott.sales@link_salesm2 ; Materialized view created.
update scott.sales set amt=500 where sid=5 Select * from sales OID 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 SID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 PID p1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 QTY 5 5 6 6 6 15 7 7 8 35 8 9 9 9 5 5 5 6 6 AMT 50 50 60 60 500 70 70 70 80 350 80 90 90 90 50 50 50 60 60 ODATE 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12 27-FEB-12
4 5 5 5 5
20 21 22 23 24
p4 p1 p2 p3 p4
6 7 7 7 8
60 70 70 70 80
d) Vertical Fragmentation Create snapshot sales2 PCTFREE 15 storage ( INITIAL 200k next 200k pctincrease 1000) using index refresh force start with sysdate next sysdate + (1/1440) as select sid,amt,pid from scott.sales@link_salesm2 Materialized view created. select * from sales2; SID 1 2 3 4 5 6 7 8 9 10 11 12 13 AMT 50 50 60 60 500 70 70 70 80 350 80 90 90 PID p1 p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4 p1
14 15 16 17 18 19 20 21 22 23 24 e) Horizontal Fragmentation
90 50 50 50 60 60 60 70 70 70 80
p2 p3 p4 p1 p2 p3 p4 p1 p2 p3 p4
Create snapshot sales PCTFREE 15 storage ( INITIAL 200k next 200k pctincrease 1000) using index refresh force start with sysdate next sysdate + (1/1440) as select * from scott.sales@link_salesm3 where pid='p1'; select * from sales1 OID 1 1 2 3 4 5 5 SID 1 p1 5 p1 9 p1 13 p1 17 p1 21 p1 25 p1 PID QTY 5 6 8 9 5 7 420 AMT ODATE 50 27-FEB-12 500 27-FEB-12 80 27-FEB-12 90 27-FEB-12 50 27-FEB-12 70 27-FEB-12 80 27-FEB-12
7 rows selected