我的java天地

          Oracle 快照及 dblink使用 (兩臺服務(wù)器數(shù)據(jù)同步)

          --名詞說明:源——被同步的數(shù)據(jù)庫
          --??????????目的——要同步到的數(shù)據(jù)庫

          /*一、創(chuàng)建dblink:*/
          --1、在目的數(shù)據(jù)庫上,創(chuàng)建dblin
          drop public?database?link?wc;
          Create?public
          database?link?wc
          Connect?to?test?identified?by?xiongwei?using?'toby';

          select * from dba_db_links;

          select * from a@wc;
          --源數(shù)據(jù)庫的用戶名、密碼、服務(wù)器名k


          /*二、創(chuàng)建快照:*/
          --1、在源和目的數(shù)據(jù)庫上同時執(zhí)行一下語句,創(chuàng)建要被同步的表
          drop?table tb_anson;
          create?table tb_anson(c1?varchar2(12));
          alter?table tb_anson add?constraint?pk_anson primary?key?(C1);

          --2、在目的數(shù)據(jù)庫上,測試dblink
          select?*?from tb_anson@dblink_anson;
          select?*?from tb_anson;

          --3、在目的數(shù)據(jù)庫上,創(chuàng)建要同步表的快照日志
          Create?snapshot?log?on?tb_anson;

          --4、創(chuàng)建快照,快照(被同步(源)數(shù)據(jù)庫服務(wù)必須啟動)
          Create?snapshot?sn_anson as?select?*?from?tb_anson@dblink_anson;

          --5、設(shè)置快照刷新時間
          Alter?snapshot anson? refresh?fast?Start?with?sysdate+1/24*60?next?sysdate+10/24*60;
          --oracle自動在1分鐘后進行第一次快速刷新,以后每隔10分鐘快速刷新一次
          Alter?snapshot anson? refresh?complete?Start?with?sysdate+30/24*60*60?next?sysdate+1;
          --oracle自動在30鈔后進行第一次完全刷新,以后每隔1天完全刷新一次

          --6、手動刷新快照
          begin
          dbms_refresh.refresh('"CS"."SN_ANSON"');
          end;

          eg:
          drop public?database link dblink_e3nfjj;
          Create public
          database link dblink_e3nfjj
          Connect to e3nfjj identified by e3nfjj using 'ORCL10_192.168.20.26';

          create table template as
          select * from template@dblink_e3nfjj;


          本用戶登錄進去的一定要能連接 'ORCL10_192.168.20.26' 這個Oracle 的SID.

          posted on 2009-04-09 21:23 tobyxiong 閱讀(484) 評論(0)  編輯  收藏 所屬分類: DATABASES

          <2009年4月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(3)

          隨筆分類(144)

          隨筆檔案(157)

          相冊

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 区。| 万全县| 岗巴县| 广灵县| 讷河市| 镇雄县| 土默特右旗| 玛沁县| 平湖市| 咸阳市| 易门县| 汕尾市| 定结县| 三穗县| 资源县| 贵定县| 襄樊市| 许昌县| 虎林市| 西华县| 衡山县| 宜兰市| 泽库县| 滕州市| 无极县| 瑞昌市| 涞源县| 临澧县| 噶尔县| 麻阳| 六安市| 海原县| 浙江省| 普宁市| 麟游县| 纳雍县| 凯里市| 依安县| 大化| 万荣县| 东台市|