gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
6.8KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>CREATE SERVER</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="sql-createsequence.html" title="CREATE SEQUENCE" /><link rel="next" href="sql-createstatistics.html" title="CREATE STATISTICS" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">CREATE SERVER</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="sql-createsequence.html" title="CREATE SEQUENCE">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="sql-commands.html" title="SQL Commands">Up</a></td><th width="60%" align="center">SQL Commands</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="sql-createstatistics.html" title="CREATE STATISTICS">Next</a></td></tr></table><hr></hr></div><div class="refentry" id="SQL-CREATESERVER"><div class="titlepage"></div><a id="id-1.9.3.82.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle">CREATE SERVER</span></h2><p>CREATE SERVER — define a new foreign server</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">
  3. CREATE SERVER [ IF NOT EXISTS ] <em class="replaceable"><code>server_name</code></em> [ TYPE '<em class="replaceable"><code>server_type</code></em>' ] [ VERSION '<em class="replaceable"><code>server_version</code></em>' ]
  4. FOREIGN DATA WRAPPER <em class="replaceable"><code>fdw_name</code></em>
  5. [ OPTIONS ( <em class="replaceable"><code>option</code></em> '<em class="replaceable"><code>value</code></em>' [, ... ] ) ]
  6. </pre></div><div class="refsect1" id="id-1.9.3.82.5"><h2>Description</h2><p>
  7. <code class="command">CREATE SERVER</code> defines a new foreign server. The
  8. user who defines the server becomes its owner.
  9. </p><p>
  10. A foreign server typically encapsulates connection information that
  11. a foreign-data wrapper uses to access an external data resource.
  12. Additional user-specific connection information may be specified by
  13. means of user mappings.
  14. </p><p>
  15. The server name must be unique within the database.
  16. </p><p>
  17. Creating a server requires <code class="literal">USAGE</code> privilege on the
  18. foreign-data wrapper being used.
  19. </p></div><div class="refsect1" id="id-1.9.3.82.6"><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="literal">IF NOT EXISTS</code></span></dt><dd><p>
  20. Do not throw an error if a server with the same name already exists.
  21. A notice is issued in this case. Note that there is no guarantee that
  22. the existing server is anything like the one that would have been
  23. created.
  24. </p></dd><dt><span class="term"><em class="replaceable"><code>server_name</code></em></span></dt><dd><p>
  25. The name of the foreign server to be created.
  26. </p></dd><dt><span class="term"><em class="replaceable"><code>server_type</code></em></span></dt><dd><p>
  27. Optional server type, potentially useful to foreign-data wrappers.
  28. </p></dd><dt><span class="term"><em class="replaceable"><code>server_version</code></em></span></dt><dd><p>
  29. Optional server version, potentially useful to foreign-data wrappers.
  30. </p></dd><dt><span class="term"><em class="replaceable"><code>fdw_name</code></em></span></dt><dd><p>
  31. The name of the foreign-data wrapper that manages the server.
  32. </p></dd><dt><span class="term"><code class="literal">OPTIONS ( <em class="replaceable"><code>option</code></em> '<em class="replaceable"><code>value</code></em>' [, ... ] )</code></span></dt><dd><p>
  33. This clause specifies the options for the server. The options
  34. typically define the connection details of the server, but the
  35. actual names and values are dependent on the server's
  36. foreign-data wrapper.
  37. </p></dd></dl></div></div><div class="refsect1" id="id-1.9.3.82.7"><h2>Notes</h2><p>
  38. When using the <a class="xref" href="dblink.html" title="F.10. dblink">dblink</a> module,
  39. a foreign server's name can be used
  40. as an argument of the <a class="xref" href="contrib-dblink-connect.html" title="dblink_connect"><span class="refentrytitle">dblink_connect</span></a>
  41. function to indicate the connection parameters. It is necessary to have
  42. the <code class="literal">USAGE</code> privilege on the foreign server to be
  43. able to use it in this way.
  44. </p></div><div class="refsect1" id="id-1.9.3.82.8"><h2>Examples</h2><p>
  45. Create a server <code class="literal">myserver</code> that uses the
  46. foreign-data wrapper <code class="literal">postgres_fdw</code>:
  47. </p><pre class="programlisting">
  48. CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
  49. </pre><p>
  50. See <a class="xref" href="postgres-fdw.html" title="F.33. postgres_fdw">postgres_fdw</a> for more details.
  51. </p></div><div class="refsect1" id="id-1.9.3.82.9"><h2>Compatibility</h2><p>
  52. <code class="command">CREATE SERVER</code> conforms to ISO/IEC 9075-9 (SQL/MED).
  53. </p></div><div class="refsect1" id="id-1.9.3.82.10"><h2>See Also</h2><span class="simplelist"><a class="xref" href="sql-alterserver.html" title="ALTER SERVER"><span class="refentrytitle">ALTER SERVER</span></a>, <a class="xref" href="sql-dropserver.html" title="DROP SERVER"><span class="refentrytitle">DROP SERVER</span></a>, <a class="xref" href="sql-createforeigndatawrapper.html" title="CREATE FOREIGN DATA WRAPPER"><span class="refentrytitle">CREATE FOREIGN DATA WRAPPER</span></a>, <a class="xref" href="sql-createforeigntable.html" title="CREATE FOREIGN TABLE"><span class="refentrytitle">CREATE FOREIGN TABLE</span></a>, <a class="xref" href="sql-createusermapping.html" title="CREATE USER MAPPING"><span class="refentrytitle">CREATE USER MAPPING</span></a></span></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sql-createsequence.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="sql-commands.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="sql-createstatistics.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">CREATE SEQUENCE </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> CREATE STATISTICS</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1