{"id":63891,"date":"2025-04-29T11:43:05","date_gmt":"2025-04-29T03:43:05","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63891\/"},"modified":"2025-04-29T11:43:05","modified_gmt":"2025-04-29T03:43:05","slug":"oracle%e6%9f%a5%e7%9c%8b%e8%bf%9b%e7%a8%8bsql-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63891\/","title":{"rendered":"oracle\u67e5\u770b\u8fdb\u7a0bsql"},"content":{"rendered":"<blockquote><p>\n  \u4f7f\u7528 oracle \u67e5\u770b\u8fdb\u7a0b sql \u7684\u65b9\u6cd5\uff1a\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u67e5\u8be2 v$sql \u89c6\u56fe\u4ee5\u83b7\u53d6\u6b63\u5728\u6267\u884c\u7684 sql \u8bed\u53e5\u4fe1\u606f\uff0c\u5305\u62ec sql_id\u3001sql_text\u3001\u6267\u884c\u6b21\u6570\u7b49\u3002\u53ef\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u67e5\u770b\u8fdb\u7a0b sql\uff0c\u5982 v$session_longops\uff08\u957f\u65f6\u95f4\u8fd0\u884c\uff09\u3001v$active_session_history\uff08\u5386\u53f2\u8bb0\u5f55\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/17\/2024081718461832031.jpg\" class=\"aligncenter\" title=\"oracle\u67e5\u770b\u8fdb\u7a0bsql\u63d2\u56fe\" alt=\"oracle\u67e5\u770b\u8fdb\u7a0bsql\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 Oracle \u67e5\u770b\u8fdb\u7a0b SQL<\/strong><\/p>\n<p>\u5728 Oracle \u6570\u636e\u5e93\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u65b9\u6cd5\u6765\u67e5\u770b\u6b63\u5728\u6267\u884c\u7684 SQL \u8bed\u53e5\u3002\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 V$SQL \u89c6\u56fe\u3002<\/p>\n<p><strong>\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li> <strong>\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a<\/strong>\u4f7f\u7528 SQL*Plus\u3001SQL Developer \u6216\u5176\u4ed6\u5de5\u5177\u8fde\u63a5\u5230 Oracle \u6570\u636e\u5e93\u3002<\/li>\n<li> <strong>\u67e5\u8be2 V$SQL \u89c6\u56fe\uff1a<\/strong>\u6267\u884c\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/li>\n<\/ol>\n<pre>SELECT * FROM V$SQL;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li> <strong>\u89e3\u91ca\u7ed3\u679c\uff1a<\/strong>\u67e5\u8be2\u7ed3\u679c\u4f1a\u663e\u793a\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u6240\u6709 SQL \u8bed\u53e5\u7684\u4fe1\u606f\uff0c\u5305\u62ec\uff1a<\/li>\n<\/ol>\n<ul>\n<li> <strong>SQL_ID\uff1a<\/strong>\u8bed\u53e5\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002<\/li>\n<li> <strong>SQL_TEXT\uff1a<\/strong>\u8bed\u53e5\u7684\u5b9e\u9645\u6587\u672c\u3002<\/li>\n<li> <strong>EXECUTIONS\uff1a<\/strong>\u8bed\u53e5\u88ab\u6267\u884c\u7684\u6b21\u6570\u3002<\/li>\n<li> <strong>DISK_READS\uff1a<\/strong>\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\u4e2d\u8bfb\u53d6\u7684\u78c1\u76d8\u5757\u6570\u3002<\/li>\n<li> <strong>BUFFER_GETS\uff1a<\/strong>\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\u4e2d\u4ece\u7f13\u51b2\u533a\u83b7\u53d6\u7684\u5757\u6570\u3002<\/li>\n<li> <strong>ROWS_PROCESSED\uff1a<\/strong>\u8bed\u53e5\u5904\u7406\u7684\u884c\u6570\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u5047\u8bbe\u60a8\u6b63\u5728\u8fd0\u884c\u4ee5\u4e0b\u67e5\u8be2\uff1a<\/p>\n<pre>SELECT * FROM customers WHERE last_name LIKE 'Smith%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6267\u884c\u67e5\u8be2\u540e\uff0c\u60a8\u53ef\u4ee5\u67e5\u8be2 V$SQL \u89c6\u56fe\u4ee5\u67e5\u770b\u8be5\u8bed\u53e5\u7684\u4fe1\u606f\uff1a<\/p>\n<pre>SELECT * FROM V$SQL WHERE SQL_TEXT LIKE '%SELECT * FROM customers WHERE last_name LIKE ''Smith%%''%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7ed3\u679c\u5c06\u663e\u793a\u8be5\u8bed\u53e5\u7684\u6267\u884c\u7edf\u8ba1\u4fe1\u606f\uff0c\u4f8b\u5982\u6267\u884c\u6b21\u6570\u3001\u78c1\u76d8\u8bfb\u53d6\u6b21\u6570\u548c\u5904\u7406\u7684\u884c\u6570\u3002<\/p>\n<p><strong>\u5176\u4ed6\u9009\u9879\uff1a<\/strong><\/p>\n<p>\u9664\u4e86 V$SQL \u89c6\u56fe\uff0c\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u6765\u67e5\u770b\u8fdb\u7a0b SQL\uff0c\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li> <strong>V$SESSION_LONGOPS:<\/strong> \u663e\u793a\u6b63\u5728\u957f\u65f6\u95f4\u8fd0\u884c\u7684 SQL \u8bed\u53e5\u3002<\/li>\n<li> <strong>V$ACTIVE_SESSION_HISTORY:<\/strong> \u663e\u793a\u6700\u8fd1\u6267\u884c\u7684 SQL \u8bed\u53e5\u7684\u5386\u53f2\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u67e5\u770b\u8fdb\u7a0bsql\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 oracle \u67e5\u770b\u8fdb\u7a0b sql \u7684\u65b9\u6cd5\uff1a\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u67e5\u8be2 v$sql \u89c6\u56fe\u4ee5\u83b7\u53d6\u6b63\u5728\u6267\u884c\u7684 sql \u8bed\u53e5\u4fe1\u606f\uff0c\u5305\u62ec sql_id\u3001sql_text\u3001\u6267\u884c\u6b21\u6570\u7b49\u3002\u53ef\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u67e5\u770b\u8fdb\u7a0b sql\uff0c\u5982 v$session_longops\uff08\u957f\u65f6\u95f4\u8fd0\u884c\uff09\u3001v$active_session_history\uff08\u5386\u53f2\u8bb0\u5f55\uff09\u3002 \u5982\u4f55\u4f7f\u7528 Oracle \u67e5\u770b\u8fdb\u7a0b SQL \u5728 Oracle \u6570\u636e\u5e93\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd\u65b9\u6cd5\u6765\u67e5\u770b\u6b63\u5728\u6267\u884c\u7684 SQL \u8bed\u53e5\u3002\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 V$SQL \u89c6\u56fe\u3002 \u6b65\u9aa4\uff1a \u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a\u4f7f\u7528 SQL*Plus\u3001SQL Developer \u6216\u5176\u4ed6\u5de5\u5177\u8fde\u63a5\u5230 Oracle \u6570\u636e\u5e93\u3002 \u67e5\u8be2 V$SQL \u89c6\u56fe\uff1a\u6267\u884c\u4ee5\u4e0b\u67e5\u8be2\uff1a SELECT * FROM V$SQL; \u767b\u5f55\u540e\u590d\u5236 \u89e3\u91ca\u7ed3\u679c\uff1a\u67e5\u8be2\u7ed3\u679c\u4f1a\u663e\u793a\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u6240\u6709 SQL \u8bed\u53e5\u7684\u4fe1\u606f\uff0c\u5305\u62ec\uff1a SQL_ID\uff1a\u8bed\u53e5\u7684\u552f\u4e00\u6807\u8bc6\u7b26\u3002 SQL_TEXT\uff1a\u8bed\u53e5\u7684\u5b9e\u9645\u6587\u672c\u3002 EXECUTIONS\uff1a\u8bed\u53e5\u88ab\u6267\u884c\u7684\u6b21\u6570\u3002 DISK_READS\uff1a\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\u4e2d\u8bfb\u53d6\u7684\u78c1\u76d8\u5757\u6570\u3002 BUFFER_GETS\uff1a\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b\u4e2d\u4ece\u7f13\u51b2\u533a\u83b7\u53d6\u7684\u5757\u6570\u3002 ROWS_PROCESSED\uff1a\u8bed\u53e5\u5904\u7406\u7684\u884c\u6570\u3002 \u793a\u4f8b\uff1a \u5047\u8bbe\u60a8\u6b63\u5728\u8fd0\u884c\u4ee5\u4e0b\u67e5\u8be2\uff1a SELECT * FROM customers WHERE last_name [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63891","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63891","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63891"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63891\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63891"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63891"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63891"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}