{"Entry":{"collection":"sql","key":"create-foreign-data-wrapper","name":"CREATE FOREIGN DATA WRAPPER","aliases":["createforeigndatawrapper"],"metadata":{"aliases":["createforeigndatawrapper"],"changed_in":["9.1","19"],"changes":[{"from":"8.3","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":[],"removed":[]},"status":"added","synopsis":null,"to":"8.4"},{"from":"9.0","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes","examples","compatibility"],"removed":[]},"status":"changed","synopsis":{"added":["[ HANDLER handler_function | NO HANDLER ]","[ VALIDATOR validator_function | NO VALIDATOR ]"],"removed":["[ VALIDATOR valfunction | NO VALIDATOR ]"]},"to":"9.1"},{"from":"9.2","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters","notes","see_also"],"removed":[]},"status":"changed","synopsis":null,"to":"9.3"},{"from":"18","purpose_changed":false,"renamed":null,"sections":{"added":[],"changed":["parameters"],"removed":[]},"status":"changed","synopsis":{"added":["[ CONNECTION connection_function | NO CONNECTION ]","[ OPTIONS ( option 'value' [, ... ] ) ]"],"removed":[]},"to":"19"}],"content_hash":"1dc923c29cd7474dddfc6b2d6d6bd6d5310ca95eac123f9a9a957e939c2bb8f3","editorial":{},"first_version":"8.4","group":"foreign","imported_at":"2026-09-30T17:43:38.670648+08:00","last_version":"20","name":"CREATE FOREIGN DATA WRAPPER","object":"FOREIGN DATA WRAPPER","position":9000,"present_in":["8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"purpose":"define a new foreign-data wrapper","purpose_zh":"","related":["alter-foreign-data-wrapper","drop-foreign-data-wrapper","create-server","create-user-mapping","create-foreign-table"],"slug":"create-foreign-data-wrapper","source_rev":"a709ab85","synopsis":"CREATE FOREIGN DATA WRAPPER name\n[ HANDLER handler_function | NO HANDLER ]\n[ VALIDATOR validator_function | NO VALIDATOR ]\n[ CONNECTION connection_function | NO CONNECTION ]\n[ OPTIONS ( option 'value' [, ... ] ) ]","verb":"CREATE"}},"Definition":{"Collection":"sql","Key":"create-foreign-data-wrapper","SourceDatabase":"center","Version":"18","SourceTable":"sqlcmd","SourceKey":"create-foreign-data-wrapper","SourceRevision":"a709ab85","Facts":{"anchor":"SQL-CREATEFOREIGNDATAWRAPPER","file":"sql-createforeigndatawrapper.html","lang":"en","name":"CREATE FOREIGN DATA WRAPPER","purpose":"define a new foreign-data wrapper","purpose_zh":"","related":["alter-foreign-data-wrapper","drop-foreign-data-wrapper","create-server","create-user-mapping","create-foreign-table"],"sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE FOREIGN DATA WRAPPER\u003c/code\u003e creates a new foreign-data wrapper. The user who defines a foreign-data wrapper becomes its owner.\u003c/p\u003e\u003cp\u003eThe foreign-data wrapper name must be unique within the database.\u003c/p\u003e\u003cp\u003eOnly superusers can create foreign-data wrappers.\u003c/p\u003e","key":"description","title":"Description"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThe name of the foreign-data wrapper to be created.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eHANDLER \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e is the name of a previously registered function that will be called to retrieve the execution functions for foreign tables. The handler function must take no arguments, and its return type must be \u003ccode class=\"type\"\u003efdw_handler\u003c/code\u003e.\u003c/p\u003e\u003cp\u003eIt is possible to create a foreign-data wrapper with no handler function, but foreign tables using such a wrapper can only be declared, not accessed.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eVALIDATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e is the name of a previously registered function that will be called to check the generic options given to the foreign-data wrapper, as well as options for foreign servers, user mappings and foreign tables using the foreign-data wrapper. If no validator function or \u003ccode class=\"literal\"\u003eNO VALIDATOR\u003c/code\u003e is specified, then options will not be checked at creation time. (Foreign-data wrappers will possibly ignore or reject invalid option specifications at run time, depending on the implementation.) The validator function must take two arguments: one of type \u003ccode class=\"type\"\u003etext[]\u003c/code\u003e, which will contain the array of options as stored in the system catalogs, and one of type \u003ccode class=\"type\"\u003eoid\u003c/code\u003e, which will be the OID of the system catalog containing the options. The return type is ignored; the function should report invalid options using the \u003ccode class=\"function\"\u003eereport(ERROR)\u003c/code\u003e function.\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eOPTIONS ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e '\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e' [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003eThis clause specifies options for the new foreign-data wrapper. The allowed option names and values are specific to each foreign data wrapper and are validated using the foreign-data wrapper's validator function. Option names must be unique.\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"Parameters"},{"html":"\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e's foreign-data functionality is still under active development. Optimization of queries is primitive (and mostly left to the wrapper, too). Thus, there is considerable room for future performance improvements.\u003c/p\u003e","key":"notes","title":"Notes"},{"html":"\u003cp\u003eCreate a useless foreign-data wrapper \u003ccode class=\"literal\"\u003edummy\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE FOREIGN DATA WRAPPER dummy;\n\u003c/pre\u003e\u003cp\u003eCreate a foreign-data wrapper \u003ccode class=\"literal\"\u003efile\u003c/code\u003e with handler function \u003ccode class=\"literal\"\u003efile_fdw_handler\u003c/code\u003e:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;\n\u003c/pre\u003e\u003cp\u003eCreate a foreign-data wrapper \u003ccode class=\"literal\"\u003emywrapper\u003c/code\u003e with some options:\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE FOREIGN DATA WRAPPER mywrapper\n    OPTIONS (debug 'true');\n\u003c/pre\u003e","key":"examples","title":"Examples"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE FOREIGN DATA WRAPPER\u003c/code\u003e conforms to ISO/IEC 9075-9 (SQL/MED), with the exception that the \u003ccode class=\"literal\"\u003eHANDLER\u003c/code\u003e and \u003ccode class=\"literal\"\u003eVALIDATOR\u003c/code\u003e clauses are extensions and the standard clauses \u003ccode class=\"literal\"\u003eLIBRARY\u003c/code\u003e and \u003ccode class=\"literal\"\u003eLANGUAGE\u003c/code\u003e are not implemented in \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eNote, however, that the SQL/MED functionality as a whole is not yet conforming.\u003c/p\u003e","key":"compatibility","title":"Compatibility"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/alter-foreign-data-wrapper/?v=18\" title=\"ALTER FOREIGN DATA WRAPPER\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER FOREIGN DATA WRAPPER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-foreign-data-wrapper/?v=18\" title=\"DROP FOREIGN DATA WRAPPER\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP FOREIGN DATA WRAPPER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-server/?v=18\" title=\"CREATE SERVER\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SERVER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-user-mapping/?v=18\" title=\"CREATE USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE USER MAPPING\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-foreign-table/?v=18\" title=\"CREATE FOREIGN TABLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE FOREIGN TABLE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"See Also"}],"sections_same_as":"","slug":"18","synopsis_html":"CREATE FOREIGN DATA WRAPPER \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\n    [ HANDLER \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e | NO HANDLER ]\n    [ VALIDATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e | NO VALIDATOR ]\n    [ OPTIONS ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e '\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e' [, ... ] ) ]","synopsis_text":"CREATE FOREIGN DATA WRAPPER name\n[ HANDLER handler_function | NO HANDLER ]\n[ VALIDATOR validator_function | NO VALIDATOR ]\n[ OPTIONS ( option 'value' [, ... ] ) ]"},"ManualEvidence":{},"MeasuredEvidence":{}},"Text":{"Collection":"sql","Key":"create-foreign-data-wrapper","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"CREATE FOREIGN DATA WRAPPER","Summary":"定义一个新的外部数据包装器","BodyHTML":"\u003cpre\u003eCREATE FOREIGN DATA WRAPPER name\n[ HANDLER handler_function | NO HANDLER ]\n[ VALIDATOR validator_function | NO VALIDATOR ]\n[ OPTIONS ( option \u0026#39;value\u0026#39; [, ... ] ) ]\u003c/pre\u003e\u003csection\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE FOREIGN DATA WRAPPER\u003c/code\u003e创建一个新的外部数据包装器。定义该外部数据包装器的用户将成为它的拥有者。\u003c/p\u003e\u003cp\u003e外部数据包装器名称在数据库内必须唯一。\u003c/p\u003e\u003cp\u003e只有超级用户能够创建外部数据包装器。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e参数\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要创建的外部数据包装器的名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eHANDLER \u003cem\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\u003cem\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e 是一个预先注册的函数的名称，该函数将被调用以取得外部表所需的执行函数。该处理器函数不能接受任何参数，并且其返回类型必须是 \u003ccode\u003efdw_handler\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e可以创建没有处理器函数的外部数据包装器，但使用这种包装器的外部表只能被声明，不能被访问。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eVALIDATOR \u003cem\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\u003cem\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e 是一个预先注册的函数的名称，该函数将被调用以检查提供给该外部数据包装器的通用选项，以及用于外部服务器、用户映射和使用该外部数据包装器的外部表的选项。如果未指定验证器函数或者指定了 \u003ccode\u003eNO VALIDATOR\u003c/code\u003e，则在创建时不会检查这些选项。（外部数据包装器可能会在运行时忽略无效的选项声明，或者拒绝它们，这取决于其实现。）验证器函数必须接受两个参数：一个参数的类型为 \u003ccode\u003etext[]\u003c/code\u003e，其中包含系统目录中存储的选项数组；另一个参数的类型为\u003ccode\u003eoid\u003c/code\u003e，其值是包含这些选项的系统目录的 OID。返回类型会被忽略；该函数应当使用 \u003ccode\u003eereport(ERROR)\u003c/code\u003e报告无效选项。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003eOPTIONS ( \u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e \u0026#39;\u003cem\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e\u0026#39; [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e这个子句为新的外部数据包装器指定选项。允许的选项名和值都依赖于各个外部数据包装器，并通过该外部数据包装器的验证器函数进行验证。选项名必须唯一。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\u003cspan\u003ePostgreSQL\u003c/span\u003e的外部数据功能仍在积极开发中。查询优化能力还很初级，而且这项工作在很大程度上也留给了包装器本身。因此，未来在性能方面仍有相当大的改进空间。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e创建一个无用的外部数据包装器\u003ccode\u003edummy\u003c/code\u003e：\u003c/p\u003e\u003cpre\u003eCREATE FOREIGN DATA WRAPPER dummy;\n\u003c/pre\u003e\u003cp\u003e用处理器函数\u003ccode\u003efile_fdw_handler\u003c/code\u003e创建一个外部数据包装器 \u003ccode\u003efile\u003c/code\u003e：\u003c/p\u003e\u003cpre\u003eCREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;\n\u003c/pre\u003e\u003cp\u003e用一些选项创建一个外部数据包装器\u003ccode\u003emywrapper\u003c/code\u003e：\u003c/p\u003e\u003cpre\u003eCREATE FOREIGN DATA WRAPPER mywrapper\n    OPTIONS (debug \u0026#39;true\u0026#39;);\n\u003c/pre\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e兼容性\u003c/h2\u003e\u003cp\u003e\u003ccode\u003eCREATE FOREIGN DATA WRAPPER\u003c/code\u003e符合 ISO/IEC 9075-9 (SQL/MED)，但\u003ccode\u003eHANDLER\u003c/code\u003e和 \u003ccode\u003eVALIDATOR\u003c/code\u003e子句属于扩展，而标准中的 \u003ccode\u003eLIBRARY\u003c/code\u003e和\u003ccode\u003eLANGUAGE\u003c/code\u003e子句在\u003cspan\u003ePostgreSQL\u003c/span\u003e中尚未实现。\u003c/p\u003e\u003cp\u003e不过需要注意，SQL/MED 功能整体上尚未完全符合该标准。\u003c/p\u003e\u003c/section\u003e\u003csection\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/wiki/sql/alter-foreign-data-wrapper/?v=18\" title=\"ALTER FOREIGN DATA WRAPPER\" rel=\"nofollow\"\u003e\u003cspan\u003eALTER FOREIGN DATA WRAPPER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-foreign-data-wrapper/?v=18\" title=\"DROP FOREIGN DATA WRAPPER\" rel=\"nofollow\"\u003e\u003cspan\u003eDROP FOREIGN DATA WRAPPER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-server/?v=18\" title=\"CREATE SERVER\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE SERVER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-user-mapping/?v=18\" title=\"CREATE USER MAPPING\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE USER MAPPING\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-foreign-table/?v=18\" title=\"CREATE FOREIGN TABLE\" rel=\"nofollow\"\u003e\u003cspan\u003eCREATE FOREIGN TABLE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/section\u003e","SourceRevision":"1b5ca64c","ContentHash":"10b8672820d7c9c0fbaeb014760a3eced7e801a33d4d8c02bb7779d71ee6bd77","Payload":{"purpose_zh":"定义一个新的外部数据包装器","sections":[{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE FOREIGN DATA WRAPPER\u003c/code\u003e创建一个新的外部数据包装器。定义该外部数据包装器的用户将成为它的拥有者。\u003c/p\u003e\u003cp\u003e外部数据包装器名称在数据库内必须唯一。\u003c/p\u003e\u003cp\u003e只有超级用户能够创建外部数据包装器。\u003c/p\u003e","key":"description","title":"描述"},{"html":"\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e要创建的外部数据包装器的名称。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eHANDLER \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e 是一个预先注册的函数的名称，该函数将被调用以取得外部表所需的执行函数。该处理器函数不能接受任何参数，并且其返回类型必须是 \u003ccode class=\"type\"\u003efdw_handler\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e可以创建没有处理器函数的外部数据包装器，但使用这种包装器的外部表只能被声明，不能被访问。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eVALIDATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e 是一个预先注册的函数的名称，该函数将被调用以检查提供给该外部数据包装器的通用选项，以及用于外部服务器、用户映射和使用该外部数据包装器的外部表的选项。如果未指定验证器函数或者指定了 \u003ccode class=\"literal\"\u003eNO VALIDATOR\u003c/code\u003e，则在创建时不会检查这些选项。（外部数据包装器可能会在运行时忽略无效的选项声明，或者拒绝它们，这取决于其实现。）验证器函数必须接受两个参数：一个参数的类型为 \u003ccode class=\"type\"\u003etext[]\u003c/code\u003e，其中包含系统目录中存储的选项数组；另一个参数的类型为\u003ccode class=\"type\"\u003eoid\u003c/code\u003e，其值是包含这些选项的系统目录的 OID。返回类型会被忽略；该函数应当使用 \u003ccode class=\"function\"\u003eereport(ERROR)\u003c/code\u003e报告无效选项。\u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eOPTIONS ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e '\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e' [, ... ] )\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e这个子句为新的外部数据包装器指定选项。允许的选项名和值都依赖于各个外部数据包装器，并通过该外部数据包装器的验证器函数进行验证。选项名必须唯一。\u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e","key":"parameters","title":"参数"},{"html":"\u003cp\u003e\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e的外部数据功能仍在积极开发中。查询优化能力还很初级，而且这项工作在很大程度上也留给了包装器本身。因此，未来在性能方面仍有相当大的改进空间。\u003c/p\u003e","key":"notes","title":"注解"},{"html":"\u003cp\u003e创建一个无用的外部数据包装器\u003ccode class=\"literal\"\u003edummy\u003c/code\u003e：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE FOREIGN DATA WRAPPER dummy;\n\u003c/pre\u003e\u003cp\u003e用处理器函数\u003ccode class=\"literal\"\u003efile_fdw_handler\u003c/code\u003e创建一个外部数据包装器 \u003ccode class=\"literal\"\u003efile\u003c/code\u003e：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;\n\u003c/pre\u003e\u003cp\u003e用一些选项创建一个外部数据包装器\u003ccode class=\"literal\"\u003emywrapper\u003c/code\u003e：\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE FOREIGN DATA WRAPPER mywrapper\n    OPTIONS (debug 'true');\n\u003c/pre\u003e","key":"examples","title":"示例"},{"html":"\u003cp\u003e\u003ccode class=\"command\"\u003eCREATE FOREIGN DATA WRAPPER\u003c/code\u003e符合 ISO/IEC 9075-9 (SQL/MED)，但\u003ccode class=\"literal\"\u003eHANDLER\u003c/code\u003e和 \u003ccode class=\"literal\"\u003eVALIDATOR\u003c/code\u003e子句属于扩展，而标准中的 \u003ccode class=\"literal\"\u003eLIBRARY\u003c/code\u003e和\u003ccode class=\"literal\"\u003eLANGUAGE\u003c/code\u003e子句在\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e中尚未实现。\u003c/p\u003e\u003cp\u003e不过需要注意，SQL/MED 功能整体上尚未完全符合该标准。\u003c/p\u003e","key":"compatibility","title":"兼容性"},{"html":"\u003cspan class=\"simplelist\"\u003e\u003ca href=\"/wiki/sql/alter-foreign-data-wrapper/?v=18\" title=\"ALTER FOREIGN DATA WRAPPER\"\u003e\u003cspan class=\"refentrytitle\"\u003eALTER FOREIGN DATA WRAPPER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/drop-foreign-data-wrapper/?v=18\" title=\"DROP FOREIGN DATA WRAPPER\"\u003e\u003cspan class=\"refentrytitle\"\u003eDROP FOREIGN DATA WRAPPER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-server/?v=18\" title=\"CREATE SERVER\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE SERVER\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-user-mapping/?v=18\" title=\"CREATE USER MAPPING\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE USER MAPPING\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/wiki/sql/create-foreign-table/?v=18\" title=\"CREATE FOREIGN TABLE\"\u003e\u003cspan class=\"refentrytitle\"\u003eCREATE FOREIGN TABLE\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e","key":"see_also","title":"另见"}],"sections_same_as":"","synopsis_html":"CREATE FOREIGN DATA WRAPPER \u003cem class=\"replaceable\"\u003e\u003ccode\u003ename\u003c/code\u003e\u003c/em\u003e\n    [ HANDLER \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehandler_function\u003c/code\u003e\u003c/em\u003e | NO HANDLER ]\n    [ VALIDATOR \u003cem class=\"replaceable\"\u003e\u003ccode\u003evalidator_function\u003c/code\u003e\u003c/em\u003e | NO VALIDATOR ]\n    [ OPTIONS ( \u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e '\u003cem class=\"replaceable\"\u003e\u003ccode\u003evalue\u003c/code\u003e\u003c/em\u003e' [, ... ] ) ]","synopsis_text":"CREATE FOREIGN DATA WRAPPER name\n[ HANDLER handler_function | NO HANDLER ]\n[ VALIDATOR validator_function | NO VALIDATOR ]\n[ OPTIONS ( option 'value' [, ... ] ) ]"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
