我的java天地

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

          --名詞說明:源——被同步的數據庫
          --??????????目的——要同步到的數據庫

          /*一、創(chuàng)建dblink:*/
          --1、在目的數據庫上,創(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;
          --源數據庫的用戶名、密碼、服務器名k


          /*二、創(chuàng)建快照:*/
          --1、在源和目的數據庫上同時執(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、在目的數據庫上,測試dblink
          select?*?from tb_anson@dblink_anson;
          select?*?from tb_anson;

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

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

          --5、設置快照刷新時間
          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 閱讀(486) 評論(0)  編輯  收藏 所屬分類: DATABASES

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

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆分類(144)

          隨筆檔案(157)

          相冊

          最新隨筆

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 福安市| 电白县| 沙洋县| 浏阳市| 天峨县| 樟树市| 娱乐| 和顺县| 陆川县| 房产| 五寨县| 昌邑市| 宁海县| 图片| 德令哈市| 武邑县| 虹口区| 海城市| 怀柔区| 宣威市| 江门市| 大渡口区| 庐江县| 运城市| 柘城县| 亳州市| 民乐县| 湘潭县| 阜新| 日照市| 聂拉木县| 金乡县| 井陉县| 霞浦县| 雷波县| 玛曲县| 运城市| 永和县| 冀州市| 大宁县| 宁夏|