{"id":2120,"date":"2025-01-02T12:17:31","date_gmt":"2025-01-02T04:17:31","guid":{"rendered":"http:\/\/www.821121.com\/?p=2120"},"modified":"2025-05-09T22:22:50","modified_gmt":"2025-05-09T14:22:50","slug":"%e7%89%a9%e5%8c%96%e8%a7%86%e5%9b%be%e7%9a%84%e5%88%a0%e9%99%a4","status":"publish","type":"post","link":"http:\/\/www.821121.com\/?p=2120","title":{"rendered":"\u7269\u5316\u89c6\u56fe\u7684\u5220\u9664"},"content":{"rendered":"<p>\u9996\u5148\u5f3a\u8c03\u4e00\u4e0b\uff0c\u5220\u9664\u7269\u5316\u89c6\u56fe\u5e76\u4e0d\u610f\u5473\u7740\u8981\u5220\u9664\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u3002\u56e0\u4e3a\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u53ef\u4ee5\u540c\u65f6\u652f\u6301\u591a\u4e2a\u7269\u5316\u89c6\u56fe\u7684\u5237\u65b0\uff0c\u5982\u679c\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u88ab\u5220\u9664\uff0c\u90a3\u4e48\u6240\u6709\u57fa\u4e8e\u8fd9\u4e2a\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u7684\u7269\u5316\u89c6\u56fe\u65e0\u6cd5\u518d\u8fdb\u884c\u5feb\u901f\u5237\u65b0\u3002<\/p>\n<p>\u8fd9\u91cc\u8ba8\u8bba\u7684\u60c5\u51b5\u662f\uff0c\u4ec5\u6709\u4e00\u4e2a\u5feb\u901f\u5237\u65b0\u7684\u7269\u5316\u89c6\u56fe\u7684\u60c5\u51b5\uff0c\u6216\u8005\u6240\u6709\u5feb\u901f\u5237\u65b0\u7684\u7269\u5316\u89c6\u56fe\u90fd\u51c6\u5907\u91cd\u65b0\u5efa\u7acb\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u5728\u8fd9\u79cd\u524d\u63d0\u4e0b\uff0c\u5148\u5220\u9664\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u7136\u540e\u518d\u5220\u9664\u7269\u5316\u89c6\u56fe\u3002<\/p>\n<p>\u8fd8\u662f\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u6765\u8bf4\u660e\u8fd9\u79cd\u60c5\u51b5\uff1a<\/p>\n<p>SQL&gt; CREATE TABLE T AS SELECT ROWNUM ID, A.* FROM DBA_OBJECTS A WHERE 1 = 2;<\/p>\n<p>\u8868\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; CREATE TABLE T1 AS SELECT ROWNUM ID, A.* FROM DBA_OBJECTS A WHERE 1 = 2;<\/p>\n<p>\u8868\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; ALTER TABLE T ADD PRIMARY KEY (ID);<\/p>\n<p>\u8868\u5df2\u66f4\u6539\u3002<\/p>\n<p>SQL&gt; ALTER TABLE T1 ADD PRIMARY KEY (ID);<\/p>\n<p>\u8868\u5df2\u66f4\u6539\u3002<\/p>\n<p>SQL&gt; CREATE MATERIALIZED VIEW LOG ON T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u65e5\u5fd7\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; CREATE MATERIALIZED VIEW LOG ON T1;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u65e5\u5fd7\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; CREATE MATERIALIZED VIEW MV_T REFRESH FAST AS SELECT * FROM T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; CREATE MATERIALIZED VIEW MV_T1 REFRESH FAST AS SELECT * FROM T1;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; INSERT INTO T VALEUS SELECT ROWNUM, A.* FROM DBA_OBJECTS A;<\/p>\n<p>\u5df2\u521b\u5efa50677\u884c\u3002<\/p>\n<p>SQL&gt; INSERT INTO T1 VALEUS SELECT ROWNUM, A.* FROM DBA_OBJECTS A;<\/p>\n<p>\u5df2\u521b\u5efa50677\u884c\u3002<\/p>\n<p>SQL&gt; COMMIT;<\/p>\n<p>\u63d0\u4ea4\u5b8c\u6210\u3002<\/p>\n<p>\u4e0a\u9762\u5efa\u7acb\u4e86\u4e24\u5f20\u5b8c\u5168\u4e00\u6837\u7684\u8868\uff0c\u4e5f\u5efa\u7acb\u4e86\u4e24\u4e2a\u5b8c\u5168\u4e00\u6837\u7684\u7269\u5316\u89c6\u56fe\uff0c\u4e0b\u9762\u5220\u9664\u7269\u5316\u89c6\u56fe\u548c\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\uff0c\u533a\u522b\u662f\u4e00\u4e2a\u5148\u5220\u9664\u7269\u5316\u89c6\u56fe\u800c\u53e6\u4e00\u4e2a\u662f\u5148\u4ea7\u751f\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\uff1a<\/p>\n<p>SQL&gt; SET TIMING ON<br \/>\nSQL&gt; DROP MATERIALIZED VIEW MV_T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u5220\u9664\u3002<\/p>\n<p>\u5df2\u7528\u65f6\u95f4:  00: 00: 01.03<br \/>\nSQL&gt; DROP MATERIALIZED VIEW LOG ON T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u65e5\u5fd7\u5df2\u5220\u9664\u3002<\/p>\n<p>\u5df2\u7528\u65f6\u95f4:  00: 00: 00.32<br \/>\nSQL&gt; DROP MATERIALIZED VIEW LOG ON T1;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u65e5\u5fd7\u5df2\u5220\u9664\u3002<\/p>\n<p>\u5df2\u7528\u65f6\u95f4:  00: 00: 00.09<br \/>\nSQL&gt; DROP MATERIALIZED VIEW MV_T1;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u5220\u9664\u3002<\/p>\n<p>\u5df2\u7528\u65f6\u95f4:  00: 00: 00.07<\/p>\n<p>\u867d\u7136\u6d4b\u8bd5\u7684\u6570\u636e\u91cf\u5f88\u5c0f\uff0c\u4f46\u662f\u6548\u679c\u5df2\u7ecf\u5f88\u660e\u663e\u4e86\uff0c\u5148\u5220\u9664\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u7136\u540e\u518d\u5220\u9664\u7269\u5316\u89c6\u56fe\u7684\u901f\u5ea6\u8981\u6bd4\u5148\u5220\u9664\u7269\u5316\u89c6\u56fe\u540e\u5220\u9664\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u5feb\u51e0\u5341\u500d\u3002<\/p>\n<p>\u5176\u5b9e\u5982\u679c\u7406\u89e3\u7269\u5316\u89c6\u56fe\u7684\u5237\u65b0\u8fc7\u7a0b\uff0c\u5bf9\u8fd9\u4e2a\u73b0\u8c61\u5c31\u4e0d\u96be\u7406\u89e3\u4e86\u3002\u7b80\u5355\u7684\u8bf4\uff0c\u7269\u5316\u89c6\u56fe\u5728\u5220\u9664\u7684\u65f6\u5019\uff0c\u9700\u8981\u5728\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u4e2d\u6e05\u9664\u90a3\u4e9b\u53ea\u6709\u5f53\u524d\u7269\u5316\u89c6\u56fe\u9700\u8981\u7684\u8bb0\u5f55\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u5b58\u5728\u7684\u8bdd\uff0c\u7269\u5316\u89c6\u56fe\u5728\u5220\u9664\u7684\u65f6\u5019\uff0c\u9700\u8981\u5c06\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u4e2d\u6240\u6709\u5f53\u524d\u7269\u5316\u89c6\u56fe\u9700\u8981\u5237\u65b0\u7684\u8bb0\u5f55\u5220\u9664\u6389\u3002\u8fd9\u610f\u5473\u7740\u4e00\u4e2aDDL\u7684\u8bed\u53e5\u4e2d\u5305\u542b\u7740DML\u7684\u90e8\u5206\u3002\u56e0\u6b64\u8fd9\u79cd\u65b9\u5f0f\u901f\u5ea6\u6162\u662f\u663e\u7136\u7684\u4e86\u3002<\/p>\n<p>\u7531\u4e8e\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u8fd8\u53ef\u80fd\u88ab\u5176\u4ed6\u7269\u5316\u89c6\u56fe\u6240\u4f7f\u7528\uff0c\u56e0\u6b64\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u4e2d\u5220\u9664\u8bb0\u5f55\u53ea\u80fd\u4f7f\u7528DELETE\u8bed\u53e5\uff0c\u4e0b\u9762\u901a\u8fc7\u4e00\u4e2a\u4f8b\u5b50\u6765\u8bc1\u5b9e\u8fd9\u4e00\u70b9\uff1a<\/p>\n<p>SQL&gt; SET TIMING OFF<br \/>\nSQL&gt; CREATE MATERIALIZED VIEW LOG ON T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u65e5\u5fd7\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; CREATE MATERIALIZED VIEW MV_T REFRESH FAST AS SELECT * FROM T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; DELETE T WHERE ID != 1;<\/p>\n<p>\u5df2\u5220\u966450676\u884c\u3002<\/p>\n<p>SQL&gt; CREATE MATERIALIZED VIEW MV_T1 REFRESH FAST AS SELECT * FROM T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u521b\u5efa\u3002<\/p>\n<p>SQL&gt; DELETE T;<\/p>\n<p>\u5df2\u5220\u9664 1 \u884c\u3002<\/p>\n<p>SQL&gt; COMMIT;<\/p>\n<p>\u63d0\u4ea4\u5b8c\u6210\u3002<\/p>\n<p>SQL&gt; SELECT COUNT(*) FROM MLOG$_T;<\/p>\n<h2>COUNT(*)<\/h2>\n<pre><code> 50677<\/code><\/pre>\n<p>SQL&gt; DROP MATERIALIZED VIEW MV_T;<\/p>\n<p>\u5b9e\u4f53\u5316\u89c6\u56fe\u5df2\u5220\u9664\u3002<\/p>\n<p>SQL&gt; SELECT COUNT(*) FROM MLOG$_T;<\/p>\n<h2>COUNT(*)<\/h2>\n<pre><code>     1<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u4f8b\u5b50\u53ef\u4ee5\u770b\u5230\uff0c\u5728\u5220\u9664\u7269\u5316\u89c6\u56feMV_T\u65f6\uff0cOracle\u5c06\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u4e2dMV_T\u6240\u9700\u7684\u8bb0\u5f55\u5220\u9664\uff0c\u7559\u4e0b\u4e86\u5176\u4ed6\u7269\u5316\u89c6\u56fe\u4ecd\u7136\u9700\u8981\u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5bf9\u4e8e\u53ea\u6709\u4e00\u4e2a\u7269\u5316\u89c6\u56fe\u7684\u60c5\u51b5\uff0c\u5148\u5220\u9664\u7269\u5316\u89c6\u56fe\u65e5\u5fd7\u53ef\u4ee5\u907f\u514dDML\u7684\u4ea7\u751f\uff0c\u662f\u7684\u5220\u9664\u64cd\u4f5c\u66f4\u52a0\u8fc5\u901f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u5f3a\u8c03\u4e00\u4e0b\uff0c\u5220\u9664\u7269\u5316\u89c6\u56fe\u5e76\u4e0d\u610f\u5473\u7740\u8981\u5220\u9664\u7269\u5316\u89c6\u56fe<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-2120","post","type-post","status-publish","format-standard","hentry","category-oracle-12c"],"_links":{"self":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/2120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2120"}],"version-history":[{"count":1,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/2120\/revisions"}],"predecessor-version":[{"id":2121,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/2120\/revisions\/2121"}],"wp:attachment":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2120"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}