{"id":5613,"date":"2024-11-14T08:13:14","date_gmt":"2024-11-14T00:13:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5613\/"},"modified":"2024-11-14T08:13:14","modified_gmt":"2024-11-14T00:13:14","slug":"sql%e6%80%8e%e4%b9%88%e8%ae%be%e7%bd%ae%e5%a4%96%e9%83%a8%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5613\/","title":{"rendered":"sql\u600e\u4e48\u8bbe\u7f6e\u5916\u90e8\u7801"},"content":{"rendered":"<blockquote><p>\n  sql\u4e2d\u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u65b9\u6cd5\uff1a\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\u3002\u521b\u5efa\u5916\u90e8\u8868\uff0c\u5e76\u6307\u5b9a\u6570\u636e\u6e90\u548c\u6570\u636e\u683c\u5f0f\u3002\u4f7f\u7528external coding\u9009\u9879\u6307\u5b9a\u5916\u90e8\u7801\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u96c6\u8f6c\u6362\u6216\u591a\u5b57\u8282\u7f16\u7801\u3002\u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u5b57\u7b26\u96c6\u4e0e\u6570\u636e\u5e93\u5b57\u7b26\u96c6\u4e0d\u540c\uff0c\u9700\u8981\u4f7f\u7528\u5b57\u7b26\u96c6\u8f6c\u6362\u8bed\u6cd5\uff1aexternal coding [(charset = ) ]\u3002\u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\uff0c\u9700\u8981\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\u8bed\u6cd5\uff1aexternal coding (mbcs) \u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053018573758697.jpg\" class=\"aligncenter\" title=\"sql\u600e\u4e48\u8bbe\u7f6e\u5916\u90e8\u7801\u63d2\u56fe\" alt=\"sql\u600e\u4e48\u8bbe\u7f6e\u5916\u90e8\u7801\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL\u4e2d\u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u5916\u90e8\u7801\u662f\u6570\u636e\u5e93\u4e2d\u7528\u4e8e\u8868\u793a\u5916\u90e8\u6570\u636e\u6e90\u4e2d\u6570\u636e\u7684\u8f6c\u6362\u89c4\u5219\u3002\u5728SQL\u4e2d\u8bbe\u7f6e\u5916\u90e8\u7801\u53ef\u4ee5\u786e\u4fdd\u4e0d\u540c\u6570\u636e\u6e90\u4e2d\u7684\u6570\u636e\u4ee5\u517c\u5bb9\u7684\u65b9\u5f0f\u5904\u7406\u3002<\/p>\n<p><strong>\u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\uff1a<\/strong>\u4f7f\u7528CREATE EXTERNAL DATA SOURCE\u8bed\u53e5\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\uff0c\u5e76\u6307\u5b9a\u5176\u8fde\u63a5\u4fe1\u606f\u3002<\/li>\n<li> <strong>\u521b\u5efa\u5916\u90e8\u8868\uff1a<\/strong>\u4f7f\u7528CREATE EXTERNAL TABLE\u8bed\u53e5\u521b\u5efa\u5916\u90e8\u8868\uff0c\u5e76\u6307\u5b9a\u5176\u6570\u636e\u6e90\u548c\u6570\u636e\u683c\u5f0f\u3002<\/li>\n<li> <strong>\u6307\u5b9a\u5916\u90e8\u7801\uff1a<\/strong>\u5728CREATE EXTERNAL TABLE\u8bed\u53e5\u4e2d\u4f7f\u7528EXTERNAL CODING\u9009\u9879\u6307\u5b9a\u5916\u90e8\u7801\u3002\u5916\u90e8\u7801\u53ef\u4ee5\u662f\u57fa\u4e8e\u5b57\u7b26\u96c6\u6216\u591a\u5b57\u8282\u7f16\u7801\u3002<\/li>\n<\/ul>\n<p><strong>\u5b57\u7b26\u96c6\u8f6c\u6362\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u7684\u5b57\u7b26\u96c6\u4e0e\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u4e0d\u540c\uff0c\u5219\u9700\u8981\u4f7f\u7528\u5b57\u7b26\u96c6\u8f6c\u6362\u5916\u90e8\u7801\u3002\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<pre>EXTERNAL CODING \n[(CHARSET = &lt;\u5b57\u7b26\u96c6\u540d\u79f0&gt;)]<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u591a\u5b57\u8282\u7f16\u7801\uff1a<\/strong><\/p>\n<p>\u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\uff0c\u5219\u9700\u8981\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\u5916\u90e8\u7801\u3002\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<pre>EXTERNAL CODING \n(MBCS)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\u540d\u4e3amy_external_data_source\uff0c\u5e76\u4f7f\u7528\u5b57\u7b26\u96c6\u8f6c\u6362\u5916\u90e8\u7801\u5c06\u5916\u90e8\u6570\u636e\u8f6c\u6362\u4e3aUTF-8\uff1a<\/p>\n<pre>CREATE EXTERNAL DATA SOURCE my_external_data_source \nWITH (\n  CONNECTION_STRING = '...'\n);\n\nCREATE EXTERNAL TABLE my_external_table \n(\n  id INT,\n  name VARCHAR\n) \nEXTERNAL CODING \n(\n  CHARSET = 'UTF-8'\n) \nUSING (\n  DATA_SOURCE = my_external_data_source\n);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8bbe\u7f6e\u5916\u90e8\u7801\u540e\uff0c\u5916\u90e8\u6570\u636e\u8868\u7684\u5217\u5c06\u6839\u636e\u6307\u5b9a\u7684\u8f6c\u6362\u89c4\u5219\u8fdb\u884c\u8f6c\u6362\uff0c\u4ee5\u5339\u914d\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u683c\u5f0f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u600e\u4e48\u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sql\u4e2d\u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u65b9\u6cd5\uff1a\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\u3002\u521b\u5efa\u5916\u90e8\u8868\uff0c\u5e76\u6307\u5b9a\u6570\u636e\u6e90\u548c\u6570\u636e\u683c\u5f0f\u3002\u4f7f\u7528external coding\u9009\u9879\u6307\u5b9a\u5916\u90e8\u7801\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u96c6\u8f6c\u6362\u6216\u591a\u5b57\u8282\u7f16\u7801\u3002\u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u5b57\u7b26\u96c6\u4e0e\u6570\u636e\u5e93\u5b57\u7b26\u96c6\u4e0d\u540c\uff0c\u9700\u8981\u4f7f\u7528\u5b57\u7b26\u96c6\u8f6c\u6362\u8bed\u6cd5\uff1aexternal coding [(charset = ) ]\u3002\u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\uff0c\u9700\u8981\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\u8bed\u6cd5\uff1aexternal coding (mbcs) \u3002 SQL\u4e2d\u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u65b9\u6cd5 \u5916\u90e8\u7801\u662f\u6570\u636e\u5e93\u4e2d\u7528\u4e8e\u8868\u793a\u5916\u90e8\u6570\u636e\u6e90\u4e2d\u6570\u636e\u7684\u8f6c\u6362\u89c4\u5219\u3002\u5728SQL\u4e2d\u8bbe\u7f6e\u5916\u90e8\u7801\u53ef\u4ee5\u786e\u4fdd\u4e0d\u540c\u6570\u636e\u6e90\u4e2d\u7684\u6570\u636e\u4ee5\u517c\u5bb9\u7684\u65b9\u5f0f\u5904\u7406\u3002 \u8bbe\u7f6e\u5916\u90e8\u7801\u7684\u6b65\u9aa4\uff1a \u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\uff1a\u4f7f\u7528CREATE EXTERNAL DATA SOURCE\u8bed\u53e5\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\uff0c\u5e76\u6307\u5b9a\u5176\u8fde\u63a5\u4fe1\u606f\u3002 \u521b\u5efa\u5916\u90e8\u8868\uff1a\u4f7f\u7528CREATE EXTERNAL TABLE\u8bed\u53e5\u521b\u5efa\u5916\u90e8\u8868\uff0c\u5e76\u6307\u5b9a\u5176\u6570\u636e\u6e90\u548c\u6570\u636e\u683c\u5f0f\u3002 \u6307\u5b9a\u5916\u90e8\u7801\uff1a\u5728CREATE EXTERNAL TABLE\u8bed\u53e5\u4e2d\u4f7f\u7528EXTERNAL CODING\u9009\u9879\u6307\u5b9a\u5916\u90e8\u7801\u3002\u5916\u90e8\u7801\u53ef\u4ee5\u662f\u57fa\u4e8e\u5b57\u7b26\u96c6\u6216\u591a\u5b57\u8282\u7f16\u7801\u3002 \u5b57\u7b26\u96c6\u8f6c\u6362\uff1a \u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u7684\u5b57\u7b26\u96c6\u4e0e\u6570\u636e\u5e93\u7684\u5b57\u7b26\u96c6\u4e0d\u540c\uff0c\u5219\u9700\u8981\u4f7f\u7528\u5b57\u7b26\u96c6\u8f6c\u6362\u5916\u90e8\u7801\u3002\u8bed\u6cd5\u4e3a\uff1a EXTERNAL CODING [(CHARSET = &lt;\u5b57\u7b26\u96c6\u540d\u79f0&gt;)] \u767b\u5f55\u540e\u590d\u5236 \u591a\u5b57\u8282\u7f16\u7801\uff1a \u5982\u679c\u5916\u90e8\u6570\u636e\u6e90\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\uff0c\u5219\u9700\u8981\u4f7f\u7528\u591a\u5b57\u8282\u7f16\u7801\u5916\u90e8\u7801\u3002\u8bed\u6cd5\u4e3a\uff1a EXTERNAL CODING (MBCS) \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\uff1a \u4ee5\u4e0b\u793a\u4f8b\u521b\u5efa\u5916\u90e8\u6570\u636e\u6e90\u540d\u4e3amy_external_data_source\uff0c\u5e76\u4f7f\u7528\u5b57\u7b26\u96c6\u8f6c\u6362\u5916\u90e8\u7801\u5c06\u5916\u90e8\u6570\u636e\u8f6c\u6362\u4e3aUTF-8\uff1a CREATE EXTERNAL DATA SOURCE my_external_data_source WITH ( CONNECTION_STRING = &#8216;&#8230;&#8217; ); CREATE EXTERNAL TABLE my_external_table [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5613","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5613","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=5613"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5613\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}