<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; adg dml</title>
	<atom:link href="https://www.xifenfei.com/tag/adg-dml/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sat, 07 Nov 2026 15:45:44 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>Oracle 19C 备库DML重定向&#8212;DML Redirection</title>
		<link>https://www.xifenfei.com/2024/02/dml-redirection.html</link>
		<comments>https://www.xifenfei.com/2024/02/dml-redirection.html#comments</comments>
		<pubDate>Mon, 12 Feb 2024 12:48:27 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Data Guard]]></category>
		<category><![CDATA[adg dml]]></category>
		<category><![CDATA[adg_redirect_dml]]></category>
		<category><![CDATA[DML Redirection]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=10624</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2024/02/dml-redirection.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2024/02/dml-redirection.html" target="_blank">Oracle 19C 备库DML重定向&#8212;DML Redirection</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在19c之前，oracle Data Guard备用数据库上不能执行DML操作，但是，从19c开始备库就可以进行DML操作了；Active Data Guard备用数据库上运行DML操作，可以在备用数据库上运行只读应用程序，偶尔执行DML（太频繁影响主库性能），备库上的DML操作可以透明地重定向到主数据库并在主数据库上运行。也包括PL/SQL块中的DML语句。Active Data Guard会话将等待，直到将相应的更改发送到Active Data Guard备用数据库并将其应用于Active Data Guard备用数据库为止。在DML操作期间将保持读取一致性，并且运行DML的备用数据库可以查看其未提交的更改。但是，所有其他备用数据库实例只有在提交事务后才能查看这些更改。<br />
在主库上创建测试表</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select * from v$version;

BANNER
--------------------------------------------------------------------------------
BANNER_FULL
--------------------------------------------------------------------------------
BANNER_LEGACY
--------------------------------------------------------------------------------
    CON_ID
----------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.5.0.0.0
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
	 0


SQL&gt; select database_role ,open_mode from v$database;

DATABASE_ROLE	 OPEN_MODE
---------------- --------------------
PRIMARY 	 READ WRITE

SQL&gt; create table system.t_xff as select * from dba_objects;

Table created.

SQL&gt; select count(*) from system.t_xff;

  COUNT(*)
----------
     72407
</pre>
<p>在备库上进行dml操作</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select database_role ,open_mode from v$database;

DATABASE_ROLE	 OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY



SQL&gt; select count(*) from system.t_xff;

  COUNT(*)
----------
     72407

SQL&gt; alter session enable adg_redirect_dml;

Session altered.

SQL&gt; delete from system.t_xff;

72407 rows deleted.

SQL&gt; commit;

Commit complete.

</pre>
<p>在主库上验证备库dml操作结果</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select count(*) from system.t_xff;

  COUNT(*)
----------
	 0

SQL&gt; 
</pre>
<p>在18c中可以通过_enable_proxy_adg_redirect隐含参数实现dml重定向</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/01/oracle-user-read-only.html" rel="bookmark" class="crp_title">Oracle read only用户&#8212;23ai新特性:只读用户</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2019/09/standby-modify-password-delay.html" rel="bookmark" class="crp_title">oracle active dataguard修改密码备库延迟生效</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/12/exadata%e4%b8%8e%e9%9d%9eexadata%e6%90%ad%e5%bb%badatagurad%e5%85%b3%e4%ba%8eehcc%e7%89%b9%e6%80%a7%e6%b5%8b%e8%af%95.html" rel="bookmark" class="crp_title">EXADATA与非EXADATA搭建DATAGURAD关于EHCC特性测试</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2018/02/18c-cancel-sql.html" rel="bookmark" class="crp_title">18c新特性：alter system cancel sql</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/06/11g-rac-to-11g-rac-adg-switchover.html" rel="bookmark" class="crp_title">11G RAC TO 11G RAC ADG SWITCHOVER</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2018/03/flashback-dataguard-failover.html" rel="bookmark" class="crp_title">dataguard配合flashback实现主备任意切换(failover和switchover)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/oracle_rowid%e5%88%86%e6%9e%90.html" rel="bookmark" class="crp_title">ORACLE ROWID 分析</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2017/11/move-lob-index-unusable.html" rel="bookmark" class="crp_title">move lob导致index失效</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/12/%e9%80%9a%e8%bf%87rowid%e6%89%be%e5%9b%9e%e5%9d%8f%e5%9d%97%e6%95%b0%e6%8d%ae.html" rel="bookmark" class="crp_title">通过ROWID找回坏块数据</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2024/07/grant-select-any-table-on-schema.html" rel="bookmark" class="crp_title">Oracle23ai新特性&#8212;SCHEMA级授权( grant select any table on schema)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/%e9%80%9a%e8%bf%87%e4%bf%ae%e6%94%b9col-col%e6%94%b9%e5%8f%98%e5%88%97%e5%b1%95%e7%a4%ba%e9%a1%ba%e5%ba%8f.html" rel="bookmark" class="crp_title">通过修改col$.col#改变列展示顺序</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/%e6%8e%88%e6%9d%83%e7%94%a8%e6%88%b7%e8%ae%bf%e9%97%ae%e6%95%b0%e6%8d%ae%e5%ad%97%e5%85%b8%e4%b8%89%e7%a7%8d%e6%96%b9%e5%bc%8f.html" rel="bookmark" class="crp_title">授权用户访问数据字典三种方式</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2024/02/dml-redirection.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
