Download presentation
Presentation is loading. Please wait.
Published byMarvin Goodwin Modified over 9 years ago
1
1 All Powder Board and Ski Oracle 9i Workbook Chapter 10: Distributed Databases Jerry Post Copyright © 2003
2
2 All Powder LAN Offices/Managers Checkout Rental Desk Network Switch Server
3
3 Create Target Database and Table Create a new database if necessary: Start/All Programs/Oracle-OraHome92/Configuration and Migration Tools/ Database Configuration Assistant Use Net Manager to add a hostname entry Log in and create a new user/schema or use the system schema Create a small table CREATE TABLE Customer ( CustomerID INTEGER, LastNameVARCHAR2(15), FirstNameVARCHAR2(15), Constraint pk_Customer Primary Key (CustomerID) ); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (1,'Smith', 'Adam'); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (2,'Keynes', 'John'); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (3,'Samuelson', 'Paul'); INSERT INTO Customer (CustomerID, LastName, FirstName) Values (4,'Robinson', 'Joan'); Commit;
4
4 Link to Target Database CREATE DATABASE LINK NewYork CONNECT TO RemoteUser IDENTIFIED BY t1 USING 'dbhostname'; SELECT * FROM Customer@NewYork; Create a descriptive name for the link User account and password on the target database Database hostname in the network file Table name@link name
5
5 Database Replicas Master Site Materialized View (Replica) Replication Group Deployment Template Link Schedule Synchronize
6
6 Create a Materialized View Replica 1.Start the Deployment Template 1.Set up Master Sites 2.Disconnect and log in as RepAdmin 3.Create a Master Group 4.Create the Template 5.Generate the script 2.Create Materialized View logs on the master site for each table 3.On the client, or build as PL/SQL to add to the script 1.Manually create a Materialized View Group creating a new Refresh Group matching name from template: CustomerTemplate 2.Select the Customer materialized view (or all) 3.Add the materialized view to the refresh group
7
7 Creating Replicas: Deployment Template-Master Site Add the main database Log in as SYSDBA Open Advanced Replication and follow menu options
8
8 Replica: Deployment: Master Group Objects tab Select Customer table
9
9 Template: Create Views Create template Select tables
10
10 Generate Template: Schema
11
11 Create Materialized View CREATE MATERIALIZED VIEW Powder.Customer FOR UPDATE AS SELECT * FROM Powder.Customer@host_database_link;
12
12 Client Side MV and Refresh Group Create refresh group Add materialized views Refresh
13
13 PL/SQL on Web Pages (0) Configure the Data Access Descriptor (DAD) (1) Create the basic html form to get the SaleIDGetSale.psp (2) Create the page to display the resultsListSales.psp (3) loadpsp -replace -user powder/ski1@PostDB GetSale.psp (4) loadpsp -replace -user powder/ski1@PostDB ListSales.psp (5) http://PostDB/pls/simpledad/Powder.GetSale Pages without JavaPages are stored as procedures within the database and use embedded PL/SQL to connect to the database Two page example to enter a SaleID and lookup the matching data
14
14 Configure DAD http://server Pick: Mod plsql Configuration Menu Modify the SimpleDAD, or create a new one Schema Name: Powder UserName: Powder Password: Connect String: PostDB Authentication Mode: Basic Leave the other defaults
15
15 GetSale.psp Form Page Get SaleID All Powder Board and Ski Shop Sales Enter a Sale ID value:
16
16 ListSales.psp Display Page List Sales Data Sales data for SaleID: Sale ID Sale Date CustomerID <% for item in (select * from sale where SaleID=l_SaleID order by SaleDate) loop %>
17
17 Load Pages Into Oracle (3) loadpsp -replace -user powder/ski1@PostDB GetSale.psp (4) loadpsp -replace -user powder/ski1@PostDB ListSales.psp Go to the command line (DOS) You must include the database name
18
18 Open the First Page in a Browser http://PostDB/pls/simpledad/powder.getsale The URL is very picky and must be complete (regardless of what the documentation says). And watch the dot! http://WebServer/pls/DADName/Schema.Procedure
19
19 Results The example is simple to highlight the steps. You can retrieve more rows. You can use a better format.
20
20 Create XML File with SQL SET long 20000 SET pages 100 SPOOL D:\Students\AllPowder\Employee10.xml SELECT XMLElement("Employee", XMLElement("LastName", LastName), XMLElement("FirstName", FirstName)) FROM Employee WHERE rownum<10; SPOOL OFF Eliminate line and page breaks Send output to a file Limit data to 9 rows to keep the file smaller for now
21
21 XML File: Cleaned Up Staff Killy Jean-Claude …
22
22 XML File in Internet Explorer
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.