{"id":2197,"date":"2026-05-22T14:46:26","date_gmt":"2026-05-22T06:46:26","guid":{"rendered":"http:\/\/www.821121.com\/?p=2197"},"modified":"2026-05-27T23:49:15","modified_gmt":"2026-05-27T15:49:15","slug":"26ai-%e6%96%b0%e7%89%b9%e6%80%a7%e4%b9%8bselect-ai%e5%ae%9e%e6%96%bd","status":"publish","type":"post","link":"http:\/\/www.821121.com\/?p=2197","title":{"rendered":"26ai \u65b0\u7279\u6027\u4e4bSELECT AI\u5b9e\u65bd"},"content":{"rendered":"<p>Oracle AI Database \u91cd\u78c5\u63a8\u51faSelect AI \u81ea\u7136\u8bed\u8a00\u8f6cSQL\uff08NL2SQL\uff09\u80fd\u529b\uff0c\u5f7b\u5e95\u98a0\u8986\u4f20\u7edf\u5f00\u53d1\u6a21\u5f0f\uff1a\u7528\u81ea\u7136\u8bed\u8a00\u63cf\u8ff0\u9700\u6c42\uff0c\u6570\u636e\u5e93\u81ea\u52a8\u751f\u6210\u3001\u6267\u884c\u3001\u89e3\u91caSQL\uff0c\u539f\u751f\u517c\u5bb9 ChatGPT\u3001Gemini\u3001Llama\u3001OCI \u539f\u751f\u5927\u6a21\u578b\u7b49\u4e3b\u6d41LLM\uff0c\u65e0\u9700\u590d\u6742\u4e8c\u6b21\u5f00\u53d1\uff0c\u5f00\u7bb1\u5373\u7528\uff0c\u5b9e\u6d4b\u53ef\u5c06\u6570\u636e\u5f00\u53d1\u3001\u62a5\u8868\u5f00\u53d1\u3001\u6570\u636e\u67e5\u8be2\u5f00\u53d1\u5468\u671f\u7f29\u77ed70%\u4ee5\u4e0a\u3002<\/p>\n<h4>\u914d\u7f6eAI\u6a21\u578b\u4e0e\u8bbf\u95ee\u51ed\u8bc1<\/h4>\n<p>\u652f\u6301\u52a8\u6001\u7ed1\u5b9a ChatGPT\u3001Gemini\u3001Llama\u3001OCI \u5927\u6a21\u578b\uff0c\u7edf\u4e00\u914d\u7f6e\u65b9\u5f0f\uff1a<\/p>\n<pre><code class=\"language-sql\">-- \u521b\u5efaAI\u51ed\u8bc1\uff08\u7ed1\u5b9a\u5bf9\u5e94LLM\u5bc6\u94a5\uff09\nBEGIN\n  DBMS_CLOUD.CREATE_CREDENTIAL(\n    credential_name =&gt; &#039;OPENAI_CRED&#039;,\n    username        =&gt; &#039;sk-xxxx&#039;,\n    password        =&gt; &#039;xxxx&#039;\n  );\nEND;\n\/\n-- \u6ce8\u518cAI\u6a21\u578b\u3001\u7ed1\u5b9aAI Profile\uff08\u6743\u9650\u7ba1\u63a7\u6a21\u677f\uff09\nBEGIN\n  DBMS_AI.CREATE_PROFILE(\n    profile_name  =&gt; &#039;NL2SQL_PROFILE&#039;,\n    model_provider=&gt; &#039;OPENAI&#039;, -- \u652f\u6301GOOGLE\u3001LLAMA\u3001OCI\u7b49\n    model_name    =&gt; &#039;gpt-4o&#039;,\n    credential    =&gt; &#039;OPENAI_CRED&#039;\n  );\nEND;\n\/<\/code><\/pre>\n<h4>\u81ea\u7136\u8bed\u8a00\u4e00\u952e\u751f\u6210\u5e76\u6267\u884cSQL<\/h4>\n<pre><code class=\"language-sql\">-- \u81ea\u7136\u8bed\u8a00\u67e5\u8be2\uff1a\u7edf\u8ba1\u8fd17\u5929\u5404\u533a\u57df\u8ba2\u5355\u91cf\u4e0e\u6210\u4ea4\u91d1\u989d\nSELECT DBMS_AI.RUN_SQL(\n  profile_name =&gt; &#039;NL2SQL_PROFILE&#039;,\n  prompt       =&gt; &#039;\u7edf\u8ba1\u8fd17\u5929\u5404\u533a\u57df\u8ba2\u5355\u603b\u91cf\u3001\u6210\u4ea4\u603b\u91d1\u989d\uff0c\u6309\u91d1\u989d\u5012\u5e8f\u6392\u5e8f&#039;\n) FROM DUAL;<\/code><\/pre>\n<h4>\u4ec5\u751f\u6210SQL\u4e0d\u6267\u884c\uff0c\u7528\u4e8e\u5f00\u53d1\u5ba1\u6838<\/h4>\n<pre><code class=\"language-sql\">SELECT DBMS_AI.SHOW_SQL(\n  profile_name =&gt; &#039;NL2SQL_PROFILE&#039;,\n  prompt       =&gt; &#039;\u67e5\u8be2\u672c\u6708\u65b0\u589e\u7528\u6237\u6570\u3001\u6d3b\u8dc3\u7528\u6237\u6570\u3001\u4ed8\u8d39\u7528\u6237\u6570&#039;\n) FROM DUAL;<\/code><\/pre>\n<h4>AI\u81ea\u52a8\u89e3\u91caSQL\u903b\u8f91<\/h4>\n<pre><code class=\"language-sql\">SELECT DBMS_AI.NARRATE(\n  profile_name =&gt; &#039;NL2SQL_PROFILE&#039;,\n  prompt       =&gt; &#039;\u89e3\u91ca\u8fd9\u6761\u8ba2\u5355\u7edf\u8ba1SQL\u7684\u6267\u884c\u903b\u8f91\u4e0e\u7edf\u8ba1\u53e3\u5f84&#039;\n) FROM DUAL;<\/code><\/pre>\n<p>\u6240\u6709\u64cd\u4f5c\u539f\u751f\u652f\u6301\u3001\u96f6\u5f00\u53d1\u3001\u96f6\u4e2d\u95f4\u4ef6\uff0c\u9002\u914d\u751f\u4ea7\u73af\u5883\u76f4\u63a5\u843d\u5730\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oracle AI Database \u91cd\u78c5\u63a8\u51faSe<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75,76],"tags":[],"class_list":["post-2197","post","type-post","status-publish","format-standard","hentry","category-oracle-26ai","category--oracle-26ai"],"_links":{"self":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/2197","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=2197"}],"version-history":[{"count":1,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/2197\/revisions"}],"predecessor-version":[{"id":2198,"href":"http:\/\/www.821121.com\/index.php?rest_route=\/wp\/v2\/posts\/2197\/revisions\/2198"}],"wp:attachment":[{"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2197"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.821121.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}