Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Oracle Streams

Oracle Streams

Ratings: (0)|Views: 910 |Likes:
Published by Partho
Here a simple example provided for Schema level Oracle streams replication
Here a simple example provided for Schema level Oracle streams replication

More info:

Published by: Partho on Jun 30, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Oracle StreamsOracle Streams enables the propagation and management of data, transactions andevents in a data stream either within a database, or from one database to another. Thestream routes published information to subscribed destinations. The result is a new featurethat provides greater functionality and flexibility than traditional solutions for capturing andmanaging events, and sharing the events with other databases and applications. As users’needs change, they can simply implement a new capability of Oracle Streams, withoutsacrificing existing capabilities.
Starting from release 9.2, Oracle has introduced a more flexible and efficient way of implementingreplication using Streams. Oracle Streams enables the sharing of data and events in a data stream, either within a database or from one database to another.In a nutshell, replication using Oracle Streams is implemented in the following way:1.-A background capture process is configured to capture changes made to tables,schemas, or the entiredatabase. The capture process captures changes from the redo log and formats each captured changeinto a logical change record (LCR). The capture process uses logminer to mine the redo/archive logs toformat LCRs.2.-The capture process enqueues LCR events into a queue that is specified.3.-This queue is scheduled to Propagate events from one queue to another in a different database.4.-A background apply process dequeues the events and applies them at the destination database.The sample code outlines the steps to set up one-way streams replication at Schema level.Partho = Global Database name of the Source (capture) SiteTanu = Global Database name of the Target (apply) SiteSTRMADMIN = Streams Administrator with password strmadminSCOTT = Source schema to be replicated – This schema is already installed on the source siteThe sample code replicates both DML and DDL.STEP 1.- Create user and the streams queue and the database links that will be used for propagation.There are two databases 1. Partho 2. Tanu.Creating a user “Strmadmin” in Partho. as well as in Tanu database.conn /as SYSDBAcreate user STRMADMIN identified by STRMADMIN;ALTER USER STRMADMIN DEFAULT TABLESPACE USERSTEMPORARY TABLESPACE TEMPQUOTA UNLIMITED ON USERS;GRANT CONNECT, RESOURCE, AQ_ADMINISTRATOR_ROLE,DBA to STRMADMIN;execute DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(’STRMADMIN’);===============================================================connect STRMADMIN/STRMADMIN@parthoBEGIN
DBMS_STREAMS_ADM.SET_UP_QUEUE(queue_table => ‘STREAMS_QUEUE_TABLE’,queue_name => ‘STREAMS_QUEUE’,queue_user => ‘STRMADMIN’);END;/PL/SQL procedure successfully completed.conn /as sysdbacreate public database link tanu using ‘tanu’;conn strmadmin/strmadmin@parthocreate database link tanu connect to strmadmin identified by strmadmin;(note, check with tnsping whether the link is working perfect or note For db link creation please check my previous article)STEP 2.- Connect as the Streams Administrator in the target site Tanu and create the streams queueconnect STRMADMIN/STRMADMIN@tanuBEGINDBMS_STREAMS_ADM.SET_UP_QUEUE(queue_table => ‘STREAMS_QUEUE_TABLE’,queue_name => ‘STREAMS_QUEUE’,queue_user => ‘STRMADMIN’);END;/PL/SQL procedure successfully completed.STEP 3.- Add apply rules for the Schema at the destination databaseSQL> BEGIN2 DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(3 schema_name => ‘SCOTT’,4 streams_type => ‘APPLY ‘,5 streams_name => ‘STREAM_APPLY’,6 queue_name => ‘STRMADMIN.STREAMS_QUEUE’,7 include_dml => true,8 include_ddl => true,9 source_database => ‘partho’);10 END;11 /PL/SQL procedure successfully completed.STEP 4.- Add capture rules for the schema SCOTT at the source databaseSQL> CONN STRMADMIN/STRMADMIN@parthoConnected.SQL> BEGIN2 DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(3 schema_name => ‘SCOTT’,4 streams_type => ‘CAPTURE’,
5 streams_name => ‘STREAM_CAPTURE’,6 queue_name => ‘STRMADMIN.STREAMS_QUEUE’,7 include_dml => true,8 include_ddl => true,9 source_database => ‘partho’);10 END;11 /PL/SQL procedure successfully completed.STEP 5.- Add propagation rules for the schema SCOTT at the source database. This step will alsocreate a propagation job to the destination databaseSQL> BEGIN2 DBMS_STREAMS_ADM.ADD_SCHEMA_PROPAGATION_RULES(3 schema_name => ‘SCOTT’,4 streams_name => ‘STREAM_PROPAGATE’,5 source_queue_name => ‘STRMADMIN.STREAMS_QUEUE’,6 destination_queue_name => ‘STRMADMIN.STREAMS_QUEUE@tanu’,7 include_dml => true,8 include_ddl => true,9 source_database => ‘partho’);10 END;11 /PL/SQL procedure successfully completed.STEP 6.- Export, import and instantiation of tables from Source to Destination Database; if the objectsare not present in the destination database, perform an export of the objects from the source databaseand import them into the destination database/* If the objects are already present in the destination database, there are two ways of instantiating theobjects at the destination site.1. By means of Metadata-only export/import :Specify ROWS=N during ExportSpecify IGNORE=Y during Import along with above import parameters.2. By Manaually instantiating the objectsGet the Instantiation SCN at the source database:SQL> connect STRMADMIN/STRMADMIN@parthoConnected.SQL> set serveroutput onSQL> DECLARE2 iscn NUMBER; Variable to hold instantiation SCN value3 BEGIN4 iscn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();5 DBMS_OUTPUT.PUT_LINE (’Instantiation SCN is: || iscn);6 END;7 /Instantiation SCN is: 1805035PL/SQL procedure successfully completed.

Activity (19)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
mkghai liked this
sairam1980 liked this
jey011 liked this
kamalshrish liked this
brijesh1747 liked this
Raj liked this
haii2009 liked this

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->