{"id":68973,"date":"2024-10-08T03:35:59","date_gmt":"2024-10-07T19:35:59","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=68973"},"modified":"2024-10-08T03:35:59","modified_gmt":"2024-10-07T19:35:59","slug":"sql-solution-ideas","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/sql-solution-ideas.html","title":{"rendered":"SQL\u65e0\u6cd5\u8d70\u7d22\u5f15\u7684\u60c5\u51b5\u53ca\u89e3\u51b3\u601d\u8def"},"content":{"rendered":"
\u4e0a\u6b21\u4e01\u4fca\u5927\u5e08\u5728\u793e\u7fa4\u4e0a\u505a\u4e86CBO\u4f18\u5316\u5668\u548c\u5751\u7239\u6848\u4f8b\u7684\u5206\u4eab\u540e\uff0c\u53cd\u54cd\u4e0d\u662f\u4e00\u822c\u7684\u5f3a\u70c8\uff0c\u4f46\u5176\u4e2d\u4e5f\u6709\u4e00\u90e8\u5206\u540c\u5b66\u8868\u793a\u592a\u9ad8\u5927\u4e0a\u4e86\uff08\u6211\u4e5f\u662f\u8fd9\u6837\u89c9\u5f97\u7684\uff09\uff0c\u6d88\u5316\u8d77\u6765\u76f8\u5f53\u6709\u96be\u5ea6\uff0c\u4e8e\u662f\u4fbf\u6709\u4e86\u672c\u6587\u3002\u7ed5\u5f00\u590d\u6742\u7684CBO\u4f18\u5316\u5668\u4e0d\u8bf4\uff0c\u672c\u6587\u5c06\u5e2e\u4f60\u7406\u6e05\u90a3\u4e9b\u56e0\u4e3aSQL\u8bed\u53e5\u7f16\u5199\u89c4\u8303\u95ee\u9898\u5bfc\u81f4\u6ca1\u6709\u5145\u5206\u5229\u7528\u7d22\u5f15\u6765\u5927\u5e45\u63d0\u5347\u6548\u7387\u7684\u4f7f\u7528\u573a\u666f\u3002<\/p>\n
\u56e0\u4e3a\u6570\u636e\u5e93\u4f18\u5316\u5668\u4e0d\u591f\u667a\u80fd\uff0c\u6216\u8005\u4e00\u4e9b\u903b\u8f91\u539f\u56e0\uff0c\u5bfc\u81f4SQL\u5728\u6bd4\u8f83\u9002\u5408\u8d70\u7d22\u5f15\u7684\u60c5\u51b5\u4e0b\u5374\u65e0\u6cd5\u6b63\u786e\u5229\u7528\u7d22\u5f15\u3002\u8fd9\u65f6\u5019\uff0c\u9664\u4e86\u7ed9\u6570\u636e\u5e93\u9700\u8981\u7684\u7edf\u8ba1\u4fe1\u606f\u4e4b\u5916\uff0cSQL\u8bed\u53e5\u672c\u8eab\u8fd8\u5fc5\u987b\u8981\u7ed9\u4f18\u5316\u5668\u8db3\u591f\u591a\u7684\u989d\u5916\u6709\u6548\u4fe1\u606f\uff0c\u5e2e\u52a9\u4f18\u5316\u5668\u80fd\u591f\u9009\u62e9\u66f4\u597d\u7684\u6267\u884c\u8ba1\u5212\u3002\u8981\u8ba9\u4f18\u5316\u5668\u6b63\u786e\u9009\u62e9\u9700\u8981\u7684\u7d22\u5f15\uff0c\u8981\u8003\u8651\u4e24\u70b9\uff1a<\/p>\n
\u8bf4\u660e\uff1a\u8fd9\u91cc\u8bf4\u7684\u8d70\u4e0d\u4e86\u7d22\u5f15\uff0c\u662f\u6307\u8d70\u4e0d\u4e86\u6b63\u5e38\u7684RANGE SCAN\uff0c\u975e(FAST) FULL INDEX SCAN\u3002<\/p>\n
SQL\u65e0\u6cd5\u8d70\u7d22\u5f15\u5e38\u89c1\u7684\u6709\u5982\u4e0b8\u79cd\u60c5\u51b5\uff1a<\/p>\n
\u7b2c\u4e00\u3001\u4e8c\u79cd\u60c5\u51b5\u5728\u73b0\u5b9e\u4e2d\u6bd4\u8f83\u5e38\u89c1\uff0c\u89e3\u51b3\u529e\u6cd5\u4e5f\u76f8\u5bf9\u6bd4\u8f83\u7b80\u5355\uff0c\u4e0b\u9762\u5c31\u4e0d\u518d\u4f5c\u8be6\u7ec6\u5c55\u5f00\u4e86\u3002<\/p>\n
\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n
\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5148\u6784\u5efa\u6d4b\u8bd5\u573a\u666f\uff1a<\/p>\n
<\/p>\n
\u8c13\u8bcd\u4f7f\u7528<>\uff0c\u65e0\u6cd5\u5229\u7528\u7d22\u5f15\uff1a<\/p>\n
<\/p>\n
\u5c06<>\u6539\u5199\u4e3aOR\u8fde\u63a5\u540e\uff0c\u80fd\u591f\u6b63\u786e\u4f7f\u7528\u7d22\u5f15\uff0c\u8d70OR\u6269\u5c55\uff1a<\/p>\n
<\/p>\n
\u5982\u679c\u4e1a\u52a1\u5141\u8bb8\uff0c\u6539\u5199\u4e3a\u4e0b\u5217\u8bed\u53e5\u4e5f\u662f\u8d70\u7d22\u5f15\u7684\uff0c\u4e0d\u518d\u6f14\u793a\u3002<\/p>\n
SELECT * FROM t\u00a0WHERE t.NAME IN (\u2018ORADB1\u2032,\u2019ORADB2\u2032,\u2019ORADB3\u2019);<\/p>\n
LIKE\u524d\u901a\u914d\u6216\u5168\u901a\u914d\u7684\u67e5\u8be2\uff0c\u8d70\u4e0d\u4e86\u7d22\u5f15<\/strong><\/p>\n \u89e3\u51b3\u65b9\u6cd5\uff0c\u6709\u5982\u4e0b\u4e09\u79cd\uff1a<\/p>\n \uff081\uff09\u6839\u636e\u4e1a\u52a1\u9700\u6c42\uff0c\u662f\u5426\u53ef\u4ee5\u628a\u524d\u901a\u914d\u53bb\u6389<\/p>\n \u539f\u6765\u5168\u901a\u914d\uff0c\u65e0\u6cd5\u8d70\u7d22\u5f15\uff1a<\/p>\n <\/p>\n \u628a\u524d\u901a\u914d\u53bb\u6389\uff0c\u6539\u4e3a\u540e\u901a\u914d\uff0c\u53ef\u4ee5\u6b63\u5e38\u4f7f\u7528\u7d22\u5f15\uff1a<\/p>\n <\/p>\n \uff082\uff09\u548c\u6b64LIKE\u4e00\u6837\u7684\u524d\u901a\u914d\u6216\u5168\u901a\u914d\u7684SQL\u6709\u5f88\u591a\uff0c\u6b64\u8c13\u8bcd\u7684LIKE\u53d8\u5316\u4e0d\u5927\uff1f\u5982\u679c\u662f\uff0c\u8003\u8651\u5efa\u7acb\u51fd\u6570\u7d22\u5f15\uff0c\u5426\u5219\u5bf9\u4e8e\u5168\u901a\u914d\u95ee\u9898\u6700\u597d\u529e\u6cd5\u5c31\u662f\u5168\u6587\u7d22\u5f15\u3002<\/p>\n \u521b\u5efainstr\u51fd\u6570\u7d22\u5f15\uff1a<\/p>\n <\/p>\n \uff083\uff09\u5982\u679c\u53ea\u662f\u524d\u901a\u914d\uff0c\u53ef\u4ee5\u4f7f\u7528reverse\u51fd\u6570\u7d22\u5f15\uff08\u4e0d\u662f\u7ffb\u8f6c\u952e\u7d22\u5f15\uff09<\/p>\n \u539f\u59cb\u8bed\u53e5\uff1a \u521b\u5efareverse\u51fd\u6570\u7d22\u5f15\uff0c\u5e76\u6539\u5199\u8bed\u53e5\uff0c\u6ce8\u610f\u67e5\u627e\u503c\u8981\u5012\u5e8f\uff1a<\/strong><\/p>\n <\/p>\n \u6ce8\u610f\uff1a<\/strong>\u5982\u679c\u901a\u914d\u67e5\u8be2\u7684\u662f\u4e2d\u6587\uff0c\u8981\u6ce8\u610f\u4f7f\u7528REVERSE\u7ffb\u8f6c\u6761\u4ef6\u503c\uff0c\u56e0\u4e3aREVERSE\u5185\u90e8\u4f1a\u6309\u5b57\u8282\u7ffb\u8f6c\u7684\uff0c\u6b63\u786e\u5199\u6cd5\u5982\uff1a<\/p>\n SELECT * FROM t WHERE REVERSE(t.name) LIKE REVERSE(\u2018\u6570\u636e\u2019)||\u2019%\u2019;<\/p><\/blockquote>\n \u5426\u5219\u67e5\u8be2\u51fa\u6765\u7684\u6570\u636e\u4e0d\u5bf9\uff0c\u5c06\u53ef\u80fd\u5f71\u54cd\u5230\u4e1a\u52a1\u7684\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n \u89e3\u51b3\u65b9\u6cd5\uff1a\u53bb\u6389\u5bf9\u7d22\u5f15\u5217\u7684\u76f8\u5173\u8fd0\u7b97\uff0c\u4fdd\u6301\u7d22\u5f15\u5217\u7eaf\u51c0\u3002<\/p>\n \u76ee\u524d\u4f18\u5316\u5668\u5bf9\u4e00\u4e9b\u6570\u5b66\u8fd0\u7b97\uff0c\u8fd8\u65e0\u6cd5\u505a\u5f88\u597d\u7684\u6d88\u9664\u52a8\u4f5c\uff0c\u6240\u4ee5\u5bf9\u4e8e\u7d22\u5f15\u5217\u5e94\u8be5\u5c3d\u91cf\u4fdd\u6301\u7eaf\u51c0\uff0c\u5426\u5219\u53ef\u80fd\u65e0\u6cd5\u7528\u4e0a\u6b63\u786e\u7684\u7d22\u5f15\u3002<\/p>\n \u4e3e\u4f8b\uff1a<\/p>\n <\/p>\n \u628a\u8bed\u53e5\u7684\u6761\u4ef6\u6539\u5199\u4e00\u4e0b\uff0c\u5c06\u8fd0\u7b97\u53bb\u6389\uff1a<\/p>\n <\/p>\n \u4ee5\u4e0a\u4f8b\u5b50\u53ea\u662f\u7b80\u5355\u7684\u6570\u5b66\u8fd0\u7b97\uff0c\u53ef\u80fd\u7684\u8fd0\u7b97\u8fd8\u6709\u548c\u5176\u4ed6\u5217\u8fd0\u7b97\uff0c\u6bd4\u5982where ID+ext_col\u2026<\/p>\n \u8bb0\u4f4f\u4e00\u4e2a\u539f\u5219\uff1a\u5c3d\u91cf\u4fdd\u6301\u7d22\u5f15\u5217\u7eaf\u51c0\u3002<\/strong><\/p>\n \u89e3\u51b3\u65b9\u6cd5\uff1a\u5fc5\u987b\u907f\u514d\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\uff0c\u5168\u90e8\u8981\u6c42\u663e\u5f0f\u7c7b\u578b\u8f6c\u6362\uff08\u975e\u7d22\u5f15\u5217\uff09\uff0c\u4e14\u907f\u514d\u5bf9\u7d22\u5f15\u5217\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\uff08\u6709\u51fd\u6570\u7d22\u5f15\u9664\u5916\uff09\u3002\u5982\u679c\u7c7b\u578b\u4e0d\u4e00\u81f4\uff0c\u4e0d\u7ba1\u662f\u5426\u53d1\u751f\u81ea\u52a8\u7c7b\u578b\u8f6c\u6362\uff0c\u8c13\u8bcd\u7684\u53f3\u503c\u5e94\u8be5\u663e\u5f0f\u8f6c\u6362\u4e3a\u4e0e\u7d22\u5f15\u5217\u4fdd\u6301\u4e00\u81f4\uff08\u5bf9\u4e8e\u975e\u7d22\u5f15\u5217\u7684\u8fd0\u7b97\u4e5f\u5e94\u8be5\u5982\u6b64\uff09\u3002<\/p>\n \u4e3e\u4f8b\uff1a<\/p>\n <\/p>\n <\/p>\n \u4ece\u4ee5\u4e0a\u4e24\u6b21\u67e5\u8be2\u5bf9\u6bd4\u6765\u770b\uff0c\u7b2c\u4e00\u6b21\u67e5\u8be2\u53d1\u751f\u4e86\u7c7b\u578b\u8f6c\u6362\uff0c\u53ef\u4ee5\u901a\u8fc7\u6267\u884c\u8ba1\u5212\u4e2d\u7684\u8c13\u8bcd\u4fe1\u606f\u83b7\u77e5\u3002\u901a\u8fc7\u5206\u6790\u53d1\u73b0\uff0cX\u56e0\u4e3a\u662fVARCHAR2\uff0c\u4f18\u5148\u7ea7\u6bd4\u6570\u503c\u7c7b\u578b\u4f4e\uff0c\u9047\u5230\u6570\u503c\u7c7b\u578b\uff0c\u4f1aTO_NUMBER\u9690\u5f0f\u8f6c\u6362\uff0c\u6240\u4ee5\u7d22\u5f15\u5931\u6548\u3002\u7b2c\u4e8c\u6b21\u67e5\u8be2\uff0c\u901a\u8fc7\u4f20\u5165\u4e0e\u7d22\u5f15\u5217\u7c7b\u578b\u4e00\u81f4\u7684\u5b57\u7b26\u4e32\u540e\uff0c\u5f97\u4ee5\u89e3\u51b3\u3002<\/p>\n \u67e5\u8be2\u8f6c\u6362\u662f\u975e\u5e38\u590d\u6742\u7684\u8fc7\u7a0b\uff0cORACLE CBO\u7684\u67e5\u8be2\u8f6c\u6362\u6709\u597d\u51e0\u5341\u79cd\uff0c\u6bd4\u5982CVM \uff1acomplex view merging \uff0cSU:subquery unnest, JPPD:JOIN PREDICATE PUSH DOWN\u7b49\uff08\u572810053\u6587\u4ef6\u91cc\u90fd\u53ef\u4ee5\u770b\u5230\uff09\u3002\u5982\u679c\u67e5\u8be2\u8f6c\u6362\u5931\u8d25\uff0c\u90a3\u4e48\u5fc5\u5c06\u5f71\u54cd\u540e\u7eed\u4f18\u5316\u5668\u7684\u4e00\u4e9b\u64cd\u4f5c\uff0c\u6bd4\u5982JPPD\u4e2dJOIN\u8c13\u8bcd\u65e0\u6cd5\u63a8\u5165\u5230\u89c6\u56fe\u4e2d\uff0c\u90a3\u4e48\u5f88\u53ef\u80fd\u89c6\u56fe\u5c31\u65e0\u6cd5\u8d70\u7d22\u5f15\u4e86\u3002\u800c\u4e14\uff0c\u67e5\u8be2\u8f6c\u6362\u6709\u5f88\u591aBUG\uff0c\u89e6\u53d1BUG\u9700\u8981\u627e\u5230\u539f\u56e0\uff0c\u6bd4\u5982\u8bbe\u7f6e\u9690\u542b\u53c2\u6570\u3001fix control\u7b49\uff0c\u6216\u8005\u6539\u5199SQL\u7ed5\u8fc7BUG\u3002\u5982\u4e0b\u4f8b\u6240\u793a\uff1a<\/p>\n <\/p>\n \u5176\u4e2dAB_XRTOFFREC_201703\u662fUNION ALL\u67e5\u8be2\u7ec4\u6210\u7684\u89c6\u56fe\uff0c\u8fd9\u4e2a\u67e5\u8be2\u572810.2.0.4\u4e0a\u5f88\u6b63\u5e38\uff0c\u5347\u7ea7\u523011.2.0.4\u540e\u6267\u884c\u8ba1\u5212\u663e\u793a\u4e0d\u8d70\u7d22\u5f15\uff0c\u6027\u80fd\u975e\u5e38\u5dee\u3002<\/p>\n \u572810g\u4e2d\u7684\u6267\u884c\u8ba1\u5212\uff1a<\/strong><\/p>\n <\/p>\n \u572811g\u4e2d\u7684\u9519\u8bef\u6267\u884c\u8ba1\u5212\uff1a<\/strong><\/p>\n <\/p>\n \u901a\u8fc7\u6536\u96c6\u7edf\u8ba1\u4fe1\u606f\u90fd\u65e0\u6548\uff0c\u5c06\u4f18\u5316\u5668\u964d\u7ea7\u523010.2.0.4\u5373\u6709\u6548\u3002\u5f88\u663e\u7136\uff0c\u8fd9\u662f\u5f15\u5165\u4e86BUG\u6216\u8005\u65b0\u7684\u9650\u5236\u3002\u4e00\u65e6\u9047\u5230\u8fd9\u79cd\u662fBUG\u6216\u9650\u5236\u5bfc\u81f4\u7684\uff0c\u53ef\u4ee5\u901a\u8fc710053\u8ddf\u8e2a\u6587\u4ef6\u6216\u8005SQLT\u6765\u8fdb\u884c\u5206\u6790\u3002\u5bf9\u4e8e\u8fd9\u6761\u8bed\u53e5\u65e0\u6cd5\u8d70JPPD\u67e5\u8be2\u8f6c\u6362\uff0c\u572810053\u4e2d\u5c31\u53ef\u4ee5\u627e\u5230\u539f\u56e0\uff1a<\/p>\n <\/p>\n \u7136\u540e\u5728MOS\u4e2d\u67e5\u770b\u5f97\u77e5\u662fBUG:9380298\uff0c\u9ed8\u8ba4\u5f00\u5173\u5173\u95ed\u3002<\/p>\n <\/p>\n ORACLE\u9488\u5bf9\u8fd9\u6837\u7684\u67e5\u8be2\uff0c\u4e3a\u4e86\u9632\u6b62\u9047\u5230\u7b1b\u5361\u5c14\u79ef\uff0c\u9ed8\u8ba4\u628a\u4fee\u590dBUG\u7684\u8865\u4e01\u5173\u95ed\u4e86\u3002\u663e\u7136\u901a\u8fc7\u8bbe\u7f6e_fix_control\u53c2\u6570\u6253\u5f009380298 fix\u5373\u53ef\u3002<\/p>\n \u4e3e\u4e00\u4e2a\u5178\u578b\u7684\u4f8b\u5b50\uff0c\u5148\u51c6\u5907\u6d4b\u8bd5\u8868\uff0c\u5e76\u5728\u5176\u4e0a\u521b\u5efa\u4e00\u4e2a\u7ec4\u5408\u7d22\u5f15\uff1a<\/p>\n <\/p>\n \u67e5\u8be2\u9700\u6c42\uff1a\u67e5\u627e\u521b\u5efa\u65f6\u95f4\u662f2013\u5e74\u7684\uff0c\u5e76\u4e14\u6700\u540eddl\u65f6\u95f4\u6bd4\u521b\u5efa\u65f6\u95f4\u59271\u5929\u4ee5\u4e0a\u7684\u5bf9\u8c61\u3002<\/p>\n <\/p>\n \u8fd9\u4e2a\u7d22\u5f15\u662f\u7ec4\u5408\u7d22\u5f15\uff0c\u4e0a\u9762\u7684\u8bed\u53e5\u5bf9\u524d\u5bfc\u5217\u8fdb\u884c\u4e86\u8fd0\u884c\uff0c\u4e5f\u4e0d\u7b26\u5408\u8d70index skip scan\u7684\u6761\u4ef6\uff0c\u6240\u4ee5\uff0c\u8d70FULL TABLE SCAN\u3002\u90a3\u4e48\u662f\u5426\u53ef\u4ee5\u901a\u8fc7\u903b\u8f91\u6539\u5199\u8d70\u7d22\u5f15\u5462\uff0c\u57fa\u4e8e\u4fdd\u6301\u7d22\u5f15\u5217\u7eaf\u51c0\u7684\u539f\u5219\uff0c\u5c06create_date\u79fb\u5230\u53f3\u8fb9\uff0c\u8bed\u53e5\u5982\u4e0b\uff1a<\/p>\n <\/p>\n \u6539\u5199\u540e\u53d1\u73b0\uff0c\u8fd8\u662f\u6ca1\u6709\u8d70\u7d22\u5f15\uff0c\u56e0\u4e3aOracle\u8ba4\u4e3a\u524d\u5bfc\u5217\u53f3\u8fb9\u7684created\u4e0d\u56fa\u5b9a\uff0c\u65e0\u6cd5\u4ece\u6307\u5b9a\u7d22\u5f15\u5904\u67e5\u627e\u3002\u901a\u8fc7\u5206\u6790\u5f97\u77e5\uff0cOracle\u8c13\u8bcd\u4f20\u9012\u6709\u4e00\u5b9a\u9650\u5236\uff0ccreate_date+1\u65e0\u6cd5\u505a\u8c13\u8bcd\u4f20\u9012\u7ed9last_ddl_time\u3002\u518d\u6b21\u6539\u5199\uff1a<\/p>\n <\/p>\n \u6b64\u65f6Oracle\u77e5\u9053\u5c06\u8c13\u8bcd\u4f20\u9012\u7ed9last_ddl_time\u4e86\uff0cT.LAST_DDL_TIME>=TO_DATE(\u2018 2013-01-01 00:00:00\u2019, \u2018syyyy-mm-dd\u00a0hh24:mi:ss\u2019)\u3002\u5f53\u7136\uff0c\u4e5f\u53ef\u4ee5\u624b\u52a8\u8c13\u8bcd\u4f20\u9012\uff0clast_ddl_time\u80af\u5b9a\u5927\u4e8e\u7b49\u4e8eDATE\u20192013-1-2\u2032<\/strong>\uff1a<\/p>\n <\/p>\n \u8fd8\u672a\u5b8c\uff0c\u6211\u4eec\u7ee7\u7eed\u5f80\u4e0b\u770b\uff1a<\/p>\n \u5982\u679c\u67e5\u8be2\u6761\u4ef6\u4e2d\u65e0t.created>=DATE\u20192013-1-1\u2019\uff0c\u5373\u5982\u4e0b\u9762\u8bed\u53e5\uff1a<\/p>\n <\/p>\n <\/p>\n \u2013\u7531\u6b64\u4e24\u6570\u636e\u6bd4\u8f83\u53ef\u77e5\uff0c\u5e94\u8be5\u8d70\u7d22\u5f15\u66f4\u4f73\u3002\u56e0\u4e3a\u6ca1\u6709\u5176\u4ed6\u8fc7\u6ee4\u6761\u4ef6\uff0c\u53ef\u4ee5\u8003\u8651\u5efa\u7acb\u51fd\u6570\u7d22\u5f15\uff1a<\/p>\n \u2013\u6ce8\u610f\u6536\u96c6\u76f4\u65b9\u56fe\uff0c\u56e0\u4e3a\u5206\u5e03\u4e0d\u5747<\/p>\n <\/p>\n \u5f53\u7136\uff0c\u5bf9\u4e8e\u4e24\u4e2a\u90fd\u662f\u8303\u56f4\u7684\u67e5\u8be2\uff0c\u8fd9\u91cc\u53ea\u80fd\u901a\u8fc7\u4e00\u4e2a\u5217\u6765\u8f6e\u8be2\u7d22\u5f15\uff0c\u5148\u505aaccess\uff0c\u518d\u505afilter\u3002<\/p>\n SQL\u8bed\u53e5\u7684\u903b\u8f91\u6539\u5199\u5f88\u91cd\u8981\uff0c\u5f80\u5f80\u901a\u8fc7\u903b\u8f91\u6539\u5199\u5c31\u80fd\u6539\u53d8SQL\u7684\u6267\u884c\u8ba1\u5212\uff0c\u4ece\u4e0d\u597d\u7684\u8ba1\u5212\u5230\u597d\u7684\u8ba1\u5212\uff0c\u6bd4\u5982semi join\uff0canti join\u4e0eor\uff0c\u5f80\u5f80\u8d70FILTER\u5bfc\u81f4\u6267\u884c\u8ba1\u5212\u8f83\u5dee\uff0c\u8fd9\u65f6\u5019\u5c31\u9700\u8981\u901a\u8fc7\u903b\u8f91\u7b49\u4ef7\u6539\u5199\u3002\u903b\u8f91\u7b49\u4ef7\u6539\u5199\u5f80\u5f80\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u96c6\u5408\u7684\u77e5\u8bc6\uff0c\u6bd4\u5982NOT (A AND B)==NOT A OR NOT B\uff0cNOT (A OR B)==NOT A AND NOT B\u7b49\u3002<\/p>\n SQL\u6709\u7d22\u5f15\u800c\u4e0d\u8d70\u7d22\u5f15\u7684\u60c5\u51b5\u8fd8\u6709\u5f88\u591a\uff0c\u6bd4\u5982\u5728DBLINK\u67e5\u8be2\u4e2d\uff0c\u53ef\u80fd\u8d70\u4e0d\u4e86\u7d22\u5f15\uff0c\u8fd9\u65f6\u5019\u9700\u8981\u901a\u8fc7driving_site hint\u6216\u8005\u8fdc\u7a0b\u5e93\u5efa\u7acb\u89c6\u56fe\u7b49\u65b9\u5f0f\u89e3\u51b3\u7b49\uff0c\u9700\u8981\u7efc\u5408\u4ece\u8bed\u6cd5\u8bed\u4e49\u3001\u7d22\u5f15\u9009\u62e9\u6027\u3001\u7d22\u5f15\u8bbf\u95ee\u7279\u70b9\u7b49\u591a\u65b9\u9762\u8fdb\u884c\u5206\u6790\u3002<\/p>\n \u4e0a\u9762\u8bf4\u5230\u7684\u95ee\u9898\uff0c\u8bf4\u5230\u5e95\u90fd\u662f\u4e0d\u9075\u5b88\u6570\u636e\u5e93\u5f00\u53d1\u89c4\u8303\u7684\u95ee\u9898\u3002\u8bf4\u5230\u6570\u636e\u5e93\u5f00\u53d1\u89c4\u8303\uff0c\u4f30\u8ba1\u5f88\u591a\u4f01\u4e1a\u90fd\u6709\u5236\u5b9a\u5bf9\u5e94\u7684\u89c4\u8303\u53ca\u8981\u6c42\uff0c\u4f46\u8bf4\u5230\u843d\u5730\u6267\u884c\u60c5\u51b5\uff0c\u8fd9\u4e2a\u5c31\u6bd4\u8f83\u56f0\u96be\u4e86\u3002\u5982\u679c\u4f01\u4e1a\u5728\u610f\u65e8\u4e0a\u662f\u671f\u671b\u5f00\u53d1\u4eba\u5458\u53bb\u5b66\u61c2\u89c4\u8303\uff0c\u7136\u540e\u5b66\u4ee5\u81f4\u7528\uff0c\u5c31\u6709\u70b9\u592a\u7406\u60f3\u5316\u4e86\u3002\u4e8e\u662f\uff0c\u4e3a\u4e86\u4fdd\u8bc1\u5f00\u53d1\u4eba\u5458\u771f\u7684\u662f\u6309\u7167\u6570\u636e\u5e93\u5f00\u53d1\u89c4\u8303\u6765\u7f16\u5199\u4ee3\u7801\uff0c\u5f88\u591a\u4f01\u4e1a\u5c31\u5728\u5e94\u7528\u4e0a\u7ebf\u524d\u589e\u52a0\u4e86\u4e00\u9053SQL\u4e0a\u7ebf\u5ba1\u6838\u7684\u5de5\u5e8f\u3002<\/p>\n \u8bf4\u5230SQL\u4e0a\u7ebf\u5ba1\u6838\uff0c\u5173\u952e\u8981\u89e3\u51b3\u4e09\u4e2a\u95ee\u9898\uff1a<\/strong><\/p>\n 1\u3001\u5982\u4f55\u5728\u4e0a\u7ebf\u7684\u5e94\u7528\u7248\u672c\u4e2d\u53d1\u73b0\u65b0\u589e\u7684SQL\u8bed\u53e5\uff1b<\/strong><\/p>\n 2\u3001\u65b0\u589eSQL\u5b58\u5728\u54ea\u4e9b\u95ee\u9898\uff0c\u5982\u4f55\u5feb\u901f\u51c6\u786e\u7684\u5b9a\u4f4d\uff1b<\/strong><\/p>\n 3\u3001\u5bf9\u4e8e\u95ee\u9898SQL\uff0c\u5982\u4f55\u5feb\u901f\u63d0\u4f9b\u4f18\u5316\u65b9\u6848\u3002<\/strong><\/p>\n \u8fd9\u4e09\u4e2a\u95ee\u9898\uff0c\u662f\u4e00\u73af\u6263\u4e00\u73af\u7684\uff0c\u89e3\u51b3\u4e0d\u4e86\u524d\u9762\u7684\u95ee\u9898\uff0c\u5c31\u65e0\u4ece\u89e3\u51b3\u540e\u9762\u7684\u95ee\u9898\u3002\u7136\u800c\uff0c\u5e94\u7528\u7cfb\u7edfSQL\u4f17\u591a\uff0c\u5982\u679c\u5355\u9760\u4eba\u5de5\uff0c\u96be\u5ea6\u662f\u5f88\u5927\u7684\uff0c\u4e13\u5bb6\u8d44\u6e90\u6295\u5165\u5c31\u66f4\u4e0d\u8bf4\u4e86\uff0c\u663e\u7136\u4e0d\u80fd\u6ee1\u8db3\u5f53\u4ecaIT\u7cfb\u7edf\u9ad8\u901f\u53d1\u5c55\u7684\u9700\u8981\u3002<\/p>\n \u8fd9\u91cc\u8ddf\u5927\u5bb6\u5206\u4eab\u6211\u4eec\u5728\u8fd9\u65b9\u9762\u7684\u4e00\u4e9b\u5b9e\u8df5\u548c\u6210\u679c\u3002\u901a\u8fc7\u7ed3\u5408\u591a\u5e74\u7684\u8fd0\u7ef4\u548c\u4f18\u5316\u7ecf\u9a8c\uff0c\u6211\u4eec\u81ea\u4e3b\u7814\u53d1\u4e86SQL\u5ba1\u6838\u5de5\u5177\uff0c\u4e0d\u4ec5\u53ef\u4ee5\u81ea\u52a8\u5316\u5b8c\u6210SQL\u4e0a\u7ebf\u5ba1\u6838\uff0c\u8fd8\u53ef\u4ee5\u505a\u5230SQL\u7684\u6027\u80fd\u76d1\u63a7\u548c\u81ea\u52a8\u4f18\u5316\uff0c\u8fbe\u5230SQL\u5168\u751f\u547d\u5468\u671f\u7ba1\u7406\u7684\u6548\u679c\u3002\u5bf9\u4e8eSQL\u4e0a\u7ebf\u5ba1\u6838\uff0c\u6211\u4eec\u5c06\u5f00\u53d1\u89c4\u8303\u89c4\u5219\u5316\u540e\u843d\u5230SQL\u5ba1\u6838\u5e73\u53f0\uff0c\u5185\u7f6e\u4e864\u4e2a\u7ef4\u5ea6\u3001200\u591a\u79cd\u5e38\u89c1\u7684\u5ba1\u67e5\u89c4\u5219\uff0c\u8fd8\u652f\u6301\u7075\u6d3b\u7684\u6309\u9700\u6dfb\u52a0\u89c4\u5219\u3002\u540c\u65f6\uff0c\u5ba1\u67e5\u7684\u4e0d\u53ea\u662fSQL\u8bed\u53e5\u672c\u8eab\uff0c\u8fd8\u5305\u62ec\u4e86\u5bf9\u8868\u7684\u6a21\u578b\u8bbe\u8ba1\u3001\u7d22\u5f15\u7684\u6784\u5efa\u3002<\/p>\n <\/p>\n \u5728\u5e94\u7528\u65b0\u7248\u672c\u4e0a\u7ebf\u524d\uff0c\u901a\u8fc7SQL\u5ba1\u6838\u5e73\u53f0\uff0c\u81ea\u52a8\u5206\u6790\u51fa\u7248\u672c\u7684\u65b0\u589eSQL\uff0c\u57fa\u4e8e\u4ee5\u4e0a\u89c4\u5219\u5bf9\u65b0\u589eSQL\u8fdb\u884c\u5ba1\u67e5\uff0c\u5e76\u81ea\u52a8\u63d0\u4f9b\u4f18\u5316\u5efa\u8bae\uff0c\u53ef\u751f\u6210\u53ef\u89c6\u5316\u7684\u62a5\u8868\u548c\u8be6\u7ec6\u62a5\u544a\u3002\u4e0d\u7ba1\u662fDBA\u8fd8\u662f\u5f00\u53d1\u4eba\u5458\u90fd\u53ef\u4ee5\u57fa\u4e8e\u6b64\u5e73\u53f0\uff0c\u5bf9\u95ee\u9898\u8fdb\u884c\u786e\u8ba4\u548c\u89e3\u51b3\uff0c\u5b9e\u73b0\u7cfb\u7edf\u4f18\u5316\u524d\u79fb\u3001\u63d0\u5347\u5e94\u7528\u7248\u672c\u8d28\u91cf\u7684\u76ee\u6807\u3002<\/p>\n <\/p>\n \u672c\u6587\u4e3b\u8981\u548c\u5927\u5bb6\u5206\u4eab\u4e86SQL\u65e0\u6cd5\u8d70\u7d22\u5f15\u7684\u4e00\u4e9b\u5e38\u89c1\u60c5\u666f\u53ca\u89e3\u51b3\u65b9\u6cd5\uff0c\u5f53\u7136\uff0cSQL\u7684\u89c4\u8303\u5316\u4f7f\u7528\u662f\u5341\u5206\u91cd\u8981\u7684\uff0cSQL\u7684\u4f18\u5316\u4e5f\u4e0d\u4ec5\u4ec5\u5c40\u9650\u4e8e\u7d22\u5f15\u7684\u4f18\u5316\u3002\u6240\u4ee5\uff0c\u53ea\u6709\u5e73\u65f6\u591a\u79ef\u7d2f\uff0c\u7ed3\u5408\u7406\u8bba\u591a\u5b9e\u8df5\uff0c\u9047\u5230\u95ee\u9898\u65f6\u624d\u80fd\u8fd0\u7b79\u5e37\u5e44\uff0c\u5bf9\u75c7\u4e0b\u836f\u3001\u836f\u5230\u75c5\u9664\u3002\u53e6\u5916\uff0c\u4f01\u4e1a\u5728IT\u5efa\u8bbe\u4e2d\u8981\u91cd\u89c6\u5f00\u53d1\u89c4\u8303\u7684\u843d\u5730\u6267\u884c\uff0c\u5fc5\u8981\u65f6\u4f7f\u7528\u5408\u9002\u7684\u5de5\u5177\uff0c\u5728\u52a0\u901fIT\u73af\u5883\u5efa\u8bbe\u6548\u7387\u7684\u540c\u65f6\uff0c\u8fd8\u80fd\u517c\u987e\u5230IT\u7cfb\u7edf\u7684\u5efa\u8bbe\u8d28\u91cf\uff0c\u505a\u5230\u4e24\u4e0d\u8bef\u3002<\/p>\n \u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.yunweipai.com\/archives\/18293.html<\/a><\/p>\n
\nSELECT \u00a0* FROM t WHERE t.NAME LIKE \u2018%ORADB1\u2019;<\/p>\nSQL> CREATE INDEX idx1_t_object ON t_objects(last_ddl_time-created);<\/pre>\n
SQL> exec dbms_stats.gather_table_stats(ownname => USER,tabname => \u2018t_objects\u2019,estimate_percent => 100,method_opt => \u2018for all indexed columns\u2019,cascade => TRUE);<\/pre>\n
\n