蚂蚁搬家
自我介绍
切换风格
订阅我的Blog
博客日历
文章归档...
最新发表...
博客统计...
网站链接...
资源
===========================================================
oracle 流技术(转),用于学习
===========================================================

Oracle 流提供了一种在数据库之间共享消息和数据的简单而灵活的方法。例如, 您可以使用流, 作为事件捕获对数据库对象所进行的 DML 和 DDL 更改。然后您可以将这些事件传播到其他数据库, 从而有效地将数据库对象复制到其他数据库。 Oracle 流包括三个主要过程:
捕获, 用来捕获对重做日志中数据库对象的更改。这些更改将放置在一个队列中。
传播, 用来将更改从源数据库中的队列传播到目标数据库中的队列。
应用, 用来从目标队列区域检索更改并应用于数据库。

使用stream流复制环境作表级或模式schema级甚至DB级的数据复制,本脚本仅供参考(详细脚本可通过OEM生成)。
(流的核心技术:Logminer+Queue):

/*************************************
设置stream流复制环境脚本(表级或模式级流复制)
Created by xsb on 2006-9-8
**************************************/
--目标库:
ACCEPT dest_dba_passwd PROMPT '请输入目标数据库 xsb2 中的用户 SYS 的口令 : ' HIDE
ACCEPT dest_strmadmin_passwd PROMPT '请输入目标数据库 xsb2 中的用户 STRMADMIN 的口令 : ' HIDE
connect
SYS/&dest_dba_passwd@xsb2 as SYSDBA

drop user strmadmin cascade;
--drop table xsb.t1 purge;
drop user xsb cascade;
grant dba to xsb identified by a;

CREATE USER strmadmin IDENTIFIED BY &dest_strmadmin_passwd
DEFAULT TABLESPACE users
QUOTA UNLIMITED ON users;
GRANT DBA TO strmadmin;
BEGIN
DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'strmadmin',
grant_privileges => true);
END;
/

pause ...
conn
strmadmin/&dest_strmadmin_passwd@xsb2
drop DATABASE LINK ORCL;
CREATE DATABASE LINK ORCL CONNECT TO strmadmin IDENTIFIED BY &dest_strmadmin_passwd
USING 'xsb';

BEGIN
DBMS_STREAMS_ADM.SET_UP_QUEUE(
queue_table => 'strmadmin.strm_queue',
queue_name => 'strmadmin.strm_queue',
queue_user => 'strmadmin');
END;
/
/*********************************************************************
--表级strm
BEGIN
DBMS_STREAMS_ADM.ADD_TABLE_RULES(
table_name => 'xsb.t1',
streams_type => 'apply',
streams_name => 'strm_apply',
queue_name => 'strmadmin.strm_queue',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => 'ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM',
inclusion_rule => true);
END;
/
*********************************************************************/
--模式级strm
BEGIN
DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
schema_name => '"XSB"',
streams_type => 'APPLY',
streams_name => 'strm_apply',
queue_name => 'strmadmin.strm_queue',
include_dml => true,
include_ddl => true,
source_database => 'ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM');
END;
/

--源库:
ACCEPT source_dba_passwd PROMPT '请输入源数据库 XSB 中的用户 SYS 的口令 : ' HIDE
connect
SYS/&source_dba_passwd@XSB as SYSDBA
/************************************************
startup mount
alter database archivelog;
alter database open;
archive log list;
************************************************/
--ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY,UNIQUE INDEX) COLUMNS;
--ALTER SYSTEM SWITCH LOGFILE;

drop user strmadmin cascade;
CREATE USER strmadmin IDENTIFIED BY &dest_strmadmin_passwd
DEFAULT TABLESPACE users
QUOTA UNLIMITED ON users;
GRANT DBA TO strmadmin;

BEGIN
DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'strmadmin',
grant_privileges => true);
END;
/

pause ...
conn
strmadmin/&dest_strmadmin_passwd@xsb
drop DATABASE LINK orcl2 ;
CREATE DATABASE LINK orcl2 CONNECT TO strmadmin IDENTIFIED BY &dest_strmadmin_passwd
USING 'xsb2';

/***************************************
CREATE DIRECTORY admin_dir AS 'e:';
BEGIN
DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
grantee => 'strmadmin',
grant_privileges => false,
file_name => 'grant_strms_privs.sql',
directory_name => 'admin_dir');
END;
/
***************************************/


BEGIN
DBMS_STREAMS_ADM.SET_UP_QUEUE(
queue_table => 'strmadmin.strm_queue',
queue_name => 'strmadmin.strm_queue',
queue_user => 'strmadmin');
END;
/

/*********************************************************************
--表级strm
BEGIN
DBMS_STREAMS_ADM.ADD_TABLE_RULES(
table_name => 'xsb.t1',
streams_type => 'capture',
streams_name => 'strm_capture',
queue_name => 'strmadmin.strm_queue',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => NULL,
inclusion_rule => true);
END;
/
BEGIN
DBMS_STREAMS_ADM.ADD_TABLE_PROPAGATION_RULES(
table_name => 'xsb.t1',
streams_name => 'strm_propagation',
source_queue_name => 'strmadmin.strm_queue',
destination_queue_name =>
'strmadmin.strm_queue@orcl2',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => 'ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM',
inclusion_rule => true,
queue_to_queue => true);
END;
/
*********************************************************************/
--模式级strm
BEGIN
DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
schema_name => '"XSB"',
streams_type => 'CAPTURE',
streams_name => 'strm_capture',
queue_name => 'strmadmin.strm_queue',
include_dml => true,
include_ddl => true,
source_database => 'ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM');
END;
/
BEGIN
DBMS_STREAMS_ADM.ADD_SCHEMA_PROPAGATION_RULES(
schema_name => '"XSB"',
streams_name => 'STRM_PROPAGATE',
source_queue_name => 'strmadmin.strm_queue',
destination_queue_name =>
'strmadmin.strm_queue@orcl2',
include_dml => true,
include_ddl => true,
source_database => 'ORCL.REGRESS.RDBMS.DEV.US.ORACLE.COM');
END;
/


--导出源
--表级
--host exp USERID="STRMADMIN"@XSB TABLES="XSB"."T1" FILE=tables.dmp GRANTS=Y ROWS=Y LOG=exportTables.log OBJECT_CONSISTENT=Y INDEXES=Y
--模式级
host exp USERID="STRMADMIN"@XSB OWNER="XSB" FILE=schemas.dmp GRANTS=Y ROWS=Y LOG=exportSchemas.log OBJECT_CONSISTENT=Y

--导入目标
--表级
--host imp USERID="STRMADMIN"@xsb2 FULL=Y CONSTRAINTS=Y FILE=tables.dmp IGNORE=Y GRANTS=Y ROWS=Y COMMIT=Y LOG=importTables.log STREAMS_CONFIGURATION=N STREAMS_INSTANTIATION=Y
--模式级
host imp USERID="STRMADMIN"@xsb2 FULL=Y CONSTRAINTS=Y FILE=schemas.dmp IGNORE=Y GRANTS=Y ROWS=Y COMMIT=Y LOG=importSchemas.log STREAMS_CONFIGURATION=N STREAMS_INSTANTIATION=Y


pause ...
--目标库
conn
strmadmin/&dest_strmadmin_passwd@xsb2
DECLARE
v_started number;
BEGIN
SELECT decode(status, 'ENABLED', 1, 0) INTO v_started
FROM DBA_APPLY WHERE APPLY_NAME = 'STRM_APPLY';

if (v_started = 0) then
DBMS_APPLY_ADM.START_APPLY(apply_name => 'STRM_APPLY');
end if;
END;
/

--源库:
conn
strmadmin/&dest_strmadmin_passwd@xsb
DECLARE
v_started number;
BEGIN
SELECT decode(status, 'ENABLED', 1, 0) INTO v_started
FROM DBA_CAPTURE WHERE CAPTURE_NAME = 'STRM_CAPTURE';

if (v_started = 0) then
DBMS_CAPTURE_ADM.START_CAPTURE(capture_name => 'STRM_CAPTURE');
end if;
END;
/

pause ...
--测试:
conn
strmadmin/&dest_strmadmin_passwd@xsb
delete xsb.t1 where id1> (select id1 from (select row_number() over(order by id1) rn ,id1 from xsb.t1 ) where rn=5);
insert into xsb.t1 select id1+(select max(id1) from xsb.t1),id2 from xsb.t1;
commit;
select * from xsb.t1;
conn
strmadmin/&dest_strmadmin_passwd@xsb2
select * from xsb.t1;
select * from xsb.t1;

http://zhouwf0726.itpub.net/post/9689/407281
一个简单的表级复制的创建过程

Streams散记之一-如何清除流配置
Ref: http://www.eygle.com/archives/2007/10/remove_streams_configuration.html


flysky0814 发表于:2007.12.18 22:32 ::分类: ( oracle10g ) ::阅读:(89266次) :: 评论 (14) :: 引用 (0)
Hey all, this is my contrabution to the forum [回复]

Hey guys. First time contributor in this great forum, so I figured I would start off with a big one.
I've read a lot of e-books and articles in my endless search on how to actually make money on
the internet, but none spelled it out quite as RsIncome - Have any of you guys tried it? It was a one
time fee for me of $12 and I think in the 2 months i've been doing it I've profited over $9,000 which is flippin
awesome!
I suggest you guys check it out ify ou want to make SERIOUS cash online, but if not, just think of this as a
hearty introduction from myself.

Cheers!
Josh

PS
For all of you who actually do want to look into it i'll provide the URL without my referral id so you KNOW i'm telling
the truth.
here you go
www.rsincome.com

Dyenemurryrip 评论于:2009.10.29 14:44
Visit VIZIMO! [回复]

3D??????????? test 3D??????????? test
?(18) ?????
??????????????????????????????? ????...
??? ???
?(17) ??
???????????
Vol.2 ????????????? ?????? Vol.2 ?????????????...
?(27) ?????
??????????1????????????1???????&?????...
????? Ver.1.1 ????? Ver.1.1
?(30) ??
???????????????????????????????(????...
?????????????? ??????????????
?(41) ?????
?????????????????????????????????????...
????? ?????
?(15) ??
?????????????
?????? ??????
?(33) ??
????????????????????????????????????...
??????? ???????
?(31) ???
??3???????????
?????? ??????
?(17) ?????
A??:?????????:???????????????:??????...
vizimo.jp/

TimaKrottto 评论于:2010.05.29 15:53
Pharmacy online: how much tramadol is too much [回复]

Buy tramadol online here:http://community.opennetcf.com/members/tramadolbuy.aspx
tramadol tablet photo man health buy tramadol tramadol drug interactions phramacology

OdriMeague 评论于:2010.06.02 20:58
hello , everybody i'am jacob [回复]

i'am glad fo find this place, i love tv shows ,games:)

[url=http://8000c.com]weight loss[/url]

Kattqueuent 评论于:2010.06.20 14:35
Exam, just a assay [回复]

Hello. And Bye.

Taspskark 评论于:2010.07.16 19:58
I have troubles with forum [回复]

I'm trying to open forum but sometimes there are no images on it :(

xXmikeniPXx 评论于:2010.07.21 18:41
Buying Spice Racks Advisor#fi [回复]

You require take a series of reasonable racks to the more new-fashioned and peerless racks that are more expensive. Spice Rack Shelf
The reasons why you get the extravagant invigorate racks are that they put up for sale you more than just hanging or storing your spices.

nekkatterup 评论于:2012.01.24 03:15
铝管可以穿强迫栏杆 [回复]

铝管提供了对抢手的温泉水输送工具 Tapered Aluminum Tubing
这种多层的难度管材,可有两个聚乙烯层之间夹一层铝管

edurnWers 评论于:2012.02.03 19:11
犷朦 [回复]

戾溻邃

JemUnance 评论于:2012.02.05 21:34
nice stuff [回复]

yet another solid entry here. is it possible in any way to cite all your sources though? would love to know where you got your info. anyway, excellent stuff.

cStephq 评论于:2012.02.17 06:59
A Guide to Baby Bath Seats [回复]

Bath measure is a scoff at and enjoyable frequently in requital for babies, children and their caregivers. The ass should must a T-bar or strap that runs between the mollycoddle's legs. When purchasing a pamper bath derriere the following should be considered: Baby Bath Seat
Baby bath seats are bathing helpers not sanctuary devices. An matured should without exception be within arm's dimension of a youngster in the bath tub.

edurnWers 评论于:2012.02.19 01:31
Test, just a test [回复]

Hello. And Bye.

XRumerTest 评论于:2012.02.26 05:26
oral sex desiese [回复]

Please visit our new free portal for adults free adult video we have only the best porn absolutely free!

infomanoria 评论于:2012.03.02 13:34
Shipping overseas [回复]

I live in a suburban community in the United States where nothing really is available. Swift-post.com has been my partner for more than two years to answer to my shopping needs

Erantystymn 评论于:2012.03.13 02:30

发表评论
标题

在此添加评论

称呼

邮箱地址(可选)

个人主页(可选)