1<!-- doc/src/sgml/postgres-fdw.sgml -->
2
3<sect1 id="postgres-fdw" xreflabel="postgres_fdw">
4 <title>postgres_fdw</title>
5
6 <indexterm zone="postgres-fdw">
7  <primary>postgres_fdw</primary>
8 </indexterm>
9
10 <para>
11  The <filename>postgres_fdw</filename> module provides the foreign-data wrapper
12  <literal>postgres_fdw</literal>, which can be used to access data
13  stored in external <productname>PostgreSQL</productname> servers.
14 </para>
15
16 <para>
17  The functionality provided by this module overlaps substantially
18  with the functionality of the older <xref linkend="dblink"/> module.
19  But <filename>postgres_fdw</filename> provides more transparent and
20  standards-compliant syntax for accessing remote tables, and can give
21  better performance in many cases.
22 </para>
23
24 <para>
25  To prepare for remote access using <filename>postgres_fdw</filename>:
26  <orderedlist spacing="compact">
27   <listitem>
28    <para>
29     Install the  <filename>postgres_fdw</filename> extension using <xref
30     linkend="sql-createextension"/>.
31    </para>
32   </listitem>
33   <listitem>
34    <para>
35     Create a foreign server object, using <xref linkend="sql-createserver"/>,
36     to represent each remote database you want to connect to.
37     Specify connection information, except <literal>user</literal> and
38     <literal>password</literal>, as options of the server object.
39    </para>
40   </listitem>
41   <listitem>
42    <para>
43     Create a user mapping, using <xref linkend="sql-createusermapping"/>, for
44     each database user you want to allow to access each foreign server.
45     Specify the remote user name and password to use as
46     <literal>user</literal> and <literal>password</literal> options of the
47     user mapping.
48    </para>
49   </listitem>
50   <listitem>
51    <para>
52     Create a foreign table, using <xref linkend="sql-createforeigntable"/>
53     or <xref linkend="sql-importforeignschema"/>,
54     for each remote table you want to access.  The columns of the foreign
55     table must match the referenced remote table.  You can, however, use
56     table and/or column names different from the remote table's, if you
57     specify the correct remote names as options of the foreign table object.
58    </para>
59   </listitem>
60  </orderedlist>
61 </para>
62
63 <para>
64  Now you need only <command>SELECT</command> from a foreign table to access
65  the data stored in its underlying remote table.  You can also modify
66  the remote table using <command>INSERT</command>, <command>UPDATE</command>, or
67  <command>DELETE</command>.  (Of course, the remote user you have specified
68  in your user mapping must have privileges to do these things.)
69 </para>
70
71 <para>
72  Note that <filename>postgres_fdw</filename> currently lacks support for
73  <command>INSERT</command> statements with an <literal>ON CONFLICT DO
74  UPDATE</literal> clause.  However, the <literal>ON CONFLICT DO NOTHING</literal>
75  clause is supported, provided a unique index inference specification
76  is omitted.
77  Note also that <filename>postgres_fdw</filename> supports row movement
78  invoked by <command>UPDATE</command> statements executed on partitioned
79  tables, but it currently does not handle the case where a remote partition
80  chosen to insert a moved row into is also an <command>UPDATE</command>
81  target partition that will be updated later.
82 </para>
83
84 <para>
85  It is generally recommended that the columns of a foreign table be declared
86  with exactly the same data types, and collations if applicable, as the
87  referenced columns of the remote table.  Although <filename>postgres_fdw</filename>
88  is currently rather forgiving about performing data type conversions at
89  need, surprising semantic anomalies may arise when types or collations do
90  not match, due to the remote server interpreting query conditions
91  differently from the local server.
92 </para>
93
94 <para>
95  Note that a foreign table can be declared with fewer columns, or with a
96  different column order, than its underlying remote table has.  Matching
97  of columns to the remote table is by name, not position.
98 </para>
99
100 <sect2>
101  <title>FDW Options of postgres_fdw</title>
102
103  <sect3>
104   <title>Connection Options</title>
105
106   <para>
107    A foreign server using the <filename>postgres_fdw</filename> foreign data wrapper
108    can have the same options that <application>libpq</application> accepts in
109    connection strings, as described in <xref linkend="libpq-paramkeywords"/>,
110    except that these options are not allowed:
111
112    <itemizedlist spacing="compact">
113     <listitem>
114      <para>
115       <literal>user</literal> and <literal>password</literal> (specify these
116       in a user mapping, instead)
117      </para>
118     </listitem>
119     <listitem>
120      <para>
121       <literal>client_encoding</literal> (this is automatically set from the local
122       server encoding)
123      </para>
124     </listitem>
125     <listitem>
126      <para>
127       <literal>fallback_application_name</literal> (always set to
128       <literal>postgres_fdw</literal>)
129      </para>
130     </listitem>
131    </itemizedlist>
132   </para>
133
134   <para>
135    Only superusers may connect to foreign servers without password
136    authentication, so always specify the <literal>password</literal> option
137    for user mappings belonging to non-superusers.
138   </para>
139  </sect3>
140
141  <sect3>
142   <title>Object Name Options</title>
143
144   <para>
145    These options can be used to control the names used in SQL statements
146    sent to the remote <productname>PostgreSQL</productname> server.  These
147    options are needed when a foreign table is created with names different
148    from the underlying remote table's names.
149   </para>
150
151   <variablelist>
152
153    <varlistentry>
154     <term><literal>schema_name</literal></term>
155     <listitem>
156      <para>
157       This option, which can be specified for a foreign table, gives the
158       schema name to use for the foreign table on the remote server.  If this
159       option is omitted, the name of the foreign table's schema is used.
160      </para>
161     </listitem>
162    </varlistentry>
163
164    <varlistentry>
165     <term><literal>table_name</literal></term>
166     <listitem>
167      <para>
168       This option, which can be specified for a foreign table, gives the
169       table name to use for the foreign table on the remote server.  If this
170       option is omitted, the foreign table's name is used.
171      </para>
172     </listitem>
173    </varlistentry>
174
175    <varlistentry>
176     <term><literal>column_name</literal></term>
177     <listitem>
178      <para>
179       This option, which can be specified for a column of a foreign table,
180       gives the column name to use for the column on the remote server.
181       If this option is omitted, the column's name is used.
182      </para>
183     </listitem>
184    </varlistentry>
185
186   </variablelist>
187
188  </sect3>
189
190  <sect3>
191   <title>Cost Estimation Options</title>
192
193   <para>
194    <filename>postgres_fdw</filename> retrieves remote data by executing queries
195    against remote servers, so ideally the estimated cost of scanning a
196    foreign table should be whatever it costs to be done on the remote
197    server, plus some overhead for communication.  The most reliable way to
198    get such an estimate is to ask the remote server and then add something
199    for overhead &mdash; but for simple queries, it may not be worth the cost
200    of an additional remote query to get a cost estimate.
201    So <filename>postgres_fdw</filename> provides the following options to control
202    how cost estimation is done:
203   </para>
204
205   <variablelist>
206
207    <varlistentry>
208     <term><literal>use_remote_estimate</literal></term>
209     <listitem>
210      <para>
211       This option, which can be specified for a foreign table or a foreign
212       server, controls whether <filename>postgres_fdw</filename> issues remote
213       <command>EXPLAIN</command> commands to obtain cost estimates.
214       A setting for a foreign table overrides any setting for its server,
215       but only for that table.
216       The default is <literal>false</literal>.
217      </para>
218     </listitem>
219    </varlistentry>
220
221    <varlistentry>
222     <term><literal>fdw_startup_cost</literal></term>
223     <listitem>
224      <para>
225       This option, which can be specified for a foreign server, is a numeric
226       value that is added to the estimated startup cost of any foreign-table
227       scan on that server.  This represents the additional overhead of
228       establishing a connection, parsing and planning the query on the
229       remote side, etc.
230       The default value is <literal>100</literal>.
231      </para>
232     </listitem>
233    </varlistentry>
234
235    <varlistentry>
236     <term><literal>fdw_tuple_cost</literal></term>
237     <listitem>
238      <para>
239       This option, which can be specified for a foreign server, is a numeric
240       value that is used as extra cost per-tuple for foreign-table
241       scans on that server.  This represents the additional overhead of
242       data transfer between servers.  You might increase or decrease this
243       number to reflect higher or lower network delay to the remote server.
244       The default value is <literal>0.01</literal>.
245      </para>
246     </listitem>
247    </varlistentry>
248
249   </variablelist>
250
251   <para>
252    When <literal>use_remote_estimate</literal> is true,
253    <filename>postgres_fdw</filename> obtains row count and cost estimates from the
254    remote server and then adds <literal>fdw_startup_cost</literal> and
255    <literal>fdw_tuple_cost</literal> to the cost estimates.  When
256    <literal>use_remote_estimate</literal> is false,
257    <filename>postgres_fdw</filename> performs local row count and cost estimation
258    and then adds <literal>fdw_startup_cost</literal> and
259    <literal>fdw_tuple_cost</literal> to the cost estimates.  This local
260    estimation is unlikely to be very accurate unless local copies of the
261    remote table's statistics are available.  Running
262    <xref linkend="sql-analyze"/> on the foreign table is the way to update
263    the local statistics; this will perform a scan of the remote table and
264    then calculate and store statistics just as though the table were local.
265    Keeping local statistics can be a useful way to reduce per-query planning
266    overhead for a remote table &mdash; but if the remote table is
267    frequently updated, the local statistics will soon be obsolete.
268   </para>
269
270  </sect3>
271
272  <sect3>
273   <title>Remote Execution Options</title>
274
275   <para>
276    By default, only <literal>WHERE</literal> clauses using built-in operators and
277    functions will be considered for execution on the remote server.  Clauses
278    involving non-built-in functions are checked locally after rows are
279    fetched.  If such functions are available on the remote server and can be
280    relied on to produce the same results as they do locally, performance can
281    be improved by sending such <literal>WHERE</literal> clauses for remote
282    execution.  This behavior can be controlled using the following option:
283   </para>
284
285   <variablelist>
286
287    <varlistentry>
288     <term><literal>extensions</literal></term>
289     <listitem>
290      <para>
291       This option is a comma-separated list of names
292       of <productname>PostgreSQL</productname> extensions that are installed, in
293       compatible versions, on both the local and remote servers.  Functions
294       and operators that are immutable and belong to a listed extension will
295       be considered shippable to the remote server.
296       This option can only be specified for foreign servers, not per-table.
297      </para>
298
299      <para>
300       When using the <literal>extensions</literal> option, <emphasis>it is the
301       user's responsibility</emphasis> that the listed extensions exist and behave
302       identically on both the local and remote servers.  Otherwise, remote
303       queries may fail or behave unexpectedly.
304      </para>
305     </listitem>
306    </varlistentry>
307
308    <varlistentry>
309     <term><literal>fetch_size</literal></term>
310     <listitem>
311      <para>
312       This option specifies the number of rows <filename>postgres_fdw</filename>
313       should get in each fetch operation. It can be specified for a foreign
314       table or a foreign server. The option specified on a table overrides
315       an option specified for the server.
316       The default is <literal>100</literal>.
317      </para>
318     </listitem>
319    </varlistentry>
320
321   </variablelist>
322
323  </sect3>
324
325  <sect3>
326   <title>Updatability Options</title>
327
328   <para>
329    By default all foreign tables using <filename>postgres_fdw</filename> are assumed
330    to be updatable.  This may be overridden using the following option:
331   </para>
332
333   <variablelist>
334
335    <varlistentry>
336     <term><literal>updatable</literal></term>
337     <listitem>
338      <para>
339       This option controls whether <filename>postgres_fdw</filename> allows foreign
340       tables to be modified using <command>INSERT</command>, <command>UPDATE</command> and
341       <command>DELETE</command> commands.  It can be specified for a foreign table
342       or a foreign server.  A table-level option overrides a server-level
343       option.
344       The default is <literal>true</literal>.
345      </para>
346
347      <para>
348       Of course, if the remote table is not in fact updatable, an error
349       would occur anyway.  Use of this option primarily allows the error to
350       be thrown locally without querying the remote server.  Note however
351       that the <literal>information_schema</literal> views will report a
352       <filename>postgres_fdw</filename> foreign table to be updatable (or not)
353       according to the setting of this option, without any check of the
354       remote server.
355      </para>
356     </listitem>
357    </varlistentry>
358
359   </variablelist>
360  </sect3>
361
362  <sect3>
363   <title>Importing Options</title>
364
365   <para>
366    <filename>postgres_fdw</filename> is able to import foreign table definitions
367    using <xref linkend="sql-importforeignschema"/>.  This command creates
368    foreign table definitions on the local server that match tables or
369    views present on the remote server.  If the remote tables to be imported
370    have columns of user-defined data types, the local server must have
371    compatible types of the same names.
372   </para>
373
374   <para>
375    Importing behavior can be customized with the following options
376    (given in the <command>IMPORT FOREIGN SCHEMA</command> command):
377   </para>
378
379   <variablelist>
380    <varlistentry>
381     <term><literal>import_collate</literal></term>
382     <listitem>
383      <para>
384       This option controls whether column <literal>COLLATE</literal> options
385       are included in the definitions of foreign tables imported
386       from a foreign server. The default is <literal>true</literal>.  You might
387       need to turn this off if the remote server has a different set of
388       collation names than the local server does, which is likely to be the
389       case if it's running on a different operating system.
390       If you do so, however, there is a very severe risk that the imported
391       table columns' collations will not match the underlying data, resulting
392       in anomalous query behavior.
393      </para>
394
395      <para>
396       Even when this parameter is set to <literal>true</literal>, importing
397       columns whose collation is the remote server's default can be risky.
398       They will be imported with <literal>COLLATE "default"</literal>, which
399       will select the local server's default collation, which could be
400       different.
401      </para>
402     </listitem>
403    </varlistentry>
404    <varlistentry>
405     <term><literal>import_default</literal></term>
406     <listitem>
407      <para>
408       This option controls whether column <literal>DEFAULT</literal> expressions
409       are included in the definitions of foreign tables imported
410       from a foreign server. The default is <literal>false</literal>.  If you
411       enable this option, be wary of defaults that might get computed
412       differently on the local server than they would be on the remote
413       server; <function>nextval()</function> is a common source of problems.
414       The <command>IMPORT</command> will fail altogether if an imported default
415       expression uses a function or operator that does not exist locally.
416      </para>
417     </listitem>
418    </varlistentry>
419    <varlistentry>
420     <term><literal>import_generated</literal></term>
421     <listitem>
422      <para>
423       This option controls whether column <literal>GENERATED</literal> expressions
424       are included in the definitions of foreign tables imported
425       from a foreign server. The default is <literal>true</literal>.
426       The <command>IMPORT</command> will fail altogether if an imported generated
427       expression uses a function or operator that does not exist locally.
428      </para>
429     </listitem>
430    </varlistentry>
431    <varlistentry>
432     <term><literal>import_not_null</literal></term>
433     <listitem>
434      <para>
435       This option controls whether column <literal>NOT NULL</literal>
436       constraints are included in the definitions of foreign tables imported
437       from a foreign server. The default is <literal>true</literal>.
438      </para>
439     </listitem>
440    </varlistentry>
441   </variablelist>
442
443   <para>
444    Note that constraints other than <literal>NOT NULL</literal> will never be
445    imported from the remote tables.  Although <productname>PostgreSQL</productname>
446    does support <literal>CHECK</literal> constraints on foreign tables, there is no
447    provision for importing them automatically, because of the risk that a
448    constraint expression could evaluate differently on the local and remote
449    servers.  Any such inconsistency in the behavior of a <literal>CHECK</literal>
450    constraint could lead to hard-to-detect errors in query optimization.
451    So if you wish to import <literal>CHECK</literal> constraints, you must do so
452    manually, and you should verify the semantics of each one carefully.
453    For more detail about the treatment of <literal>CHECK</literal> constraints on
454    foreign tables, see <xref linkend="sql-createforeigntable"/>.
455   </para>
456
457   <para>
458    Tables or foreign tables which are partitions of some other table are
459    automatically excluded.  Partitioned tables are imported, unless they
460    are a partition of some other table.  Since all data can be accessed
461    through the partitioned table which is the root of the partitioning
462    hierarchy, this approach should allow access to all the data without
463    creating extra objects.
464   </para>
465
466  </sect3>
467 </sect2>
468
469 <sect2>
470  <title>Connection Management</title>
471
472  <para>
473   <filename>postgres_fdw</filename> establishes a connection to a
474   foreign server during the first query that uses a foreign table
475   associated with the foreign server.  This connection is kept and
476   re-used for subsequent queries in the same session.  However, if
477   multiple user identities (user mappings) are used to access the foreign
478   server, a connection is established for each user mapping.
479  </para>
480 </sect2>
481
482 <sect2>
483  <title>Transaction Management</title>
484
485  <para>
486   During a query that references any remote tables on a foreign server,
487   <filename>postgres_fdw</filename> opens a transaction on the
488   remote server if one is not already open corresponding to the current
489   local transaction.  The remote transaction is committed or aborted when
490   the local transaction commits or aborts.  Savepoints are similarly
491   managed by creating corresponding remote savepoints.
492  </para>
493
494  <para>
495   The remote transaction uses <literal>SERIALIZABLE</literal>
496   isolation level when the local transaction has <literal>SERIALIZABLE</literal>
497   isolation level; otherwise it uses <literal>REPEATABLE READ</literal>
498   isolation level.  This choice ensures that if a query performs multiple
499   table scans on the remote server, it will get snapshot-consistent results
500   for all the scans.  A consequence is that successive queries within a
501   single transaction will see the same data from the remote server, even if
502   concurrent updates are occurring on the remote server due to other
503   activities.  That behavior would be expected anyway if the local
504   transaction uses <literal>SERIALIZABLE</literal> or <literal>REPEATABLE READ</literal>
505   isolation level, but it might be surprising for a <literal>READ
506   COMMITTED</literal> local transaction.  A future
507   <productname>PostgreSQL</productname> release might modify these rules.
508  </para>
509
510  <para>
511   Note that it is currently not supported by
512   <filename>postgres_fdw</filename> to prepare the remote transaction for
513   two-phase commit.
514  </para>
515 </sect2>
516
517 <sect2>
518  <title>Remote Query Optimization</title>
519
520  <para>
521   <filename>postgres_fdw</filename> attempts to optimize remote queries to reduce
522   the amount of data transferred from foreign servers.  This is done by
523   sending query <literal>WHERE</literal> clauses to the remote server for
524   execution, and by not retrieving table columns that are not needed for
525   the current query.  To reduce the risk of misexecution of queries,
526   <literal>WHERE</literal> clauses are not sent to the remote server unless they use
527   only data types, operators, and functions that are built-in or belong to an
528   extension that's listed in the foreign server's <literal>extensions</literal>
529   option.  Operators and functions in such clauses must
530   be <literal>IMMUTABLE</literal> as well.
531   For an <command>UPDATE</command> or <command>DELETE</command> query,
532   <filename>postgres_fdw</filename> attempts to optimize the query execution by
533   sending the whole query to the remote server if there are no query
534   <literal>WHERE</literal> clauses that cannot be sent to the remote server,
535   no local joins for the query, no row-level local <literal>BEFORE</literal> or
536   <literal>AFTER</literal> triggers or stored generated columns on the target
537   table, and no <literal>CHECK OPTION</literal> constraints from parent
538   views.  In <command>UPDATE</command>,
539   expressions to assign to target columns must use only built-in data types,
540   <literal>IMMUTABLE</literal> operators, or <literal>IMMUTABLE</literal> functions,
541   to reduce the risk of misexecution of the query.
542  </para>
543
544  <para>
545   When <filename>postgres_fdw</filename> encounters a join between foreign tables on
546   the same foreign server, it sends the entire join to the foreign server,
547   unless for some reason it believes that it will be more efficient to fetch
548   rows from each table individually, or unless the table references involved
549   are subject to different user mappings.  While sending the <literal>JOIN</literal>
550   clauses, it takes the same precautions as mentioned above for the
551   <literal>WHERE</literal> clauses.
552  </para>
553
554  <para>
555   The query that is actually sent to the remote server for execution can
556   be examined using <command>EXPLAIN VERBOSE</command>.
557  </para>
558 </sect2>
559
560 <sect2>
561  <title>Remote Query Execution Environment</title>
562
563  <para>
564   In the remote sessions opened by <filename>postgres_fdw</filename>,
565   the <xref linkend="guc-search-path"/> parameter is set to
566   just <literal>pg_catalog</literal>, so that only built-in objects are visible
567   without schema qualification.  This is not an issue for queries
568   generated by <filename>postgres_fdw</filename> itself, because it always
569   supplies such qualification.  However, this can pose a hazard for
570   functions that are executed on the remote server via triggers or rules
571   on remote tables.  For example, if a remote table is actually a view,
572   any functions used in that view will be executed with the restricted
573   search path.  It is recommended to schema-qualify all names in such
574   functions, or else attach <literal>SET search_path</literal> options
575   (see <xref linkend="sql-createfunction"/>) to such functions
576   to establish their expected search path environment.
577  </para>
578
579  <para>
580   <filename>postgres_fdw</filename> likewise establishes remote session settings
581   for various parameters:
582   <itemizedlist spacing="compact">
583    <listitem>
584     <para>
585      <xref linkend="guc-timezone"/> is set to <literal>UTC</literal>
586     </para>
587    </listitem>
588    <listitem>
589     <para>
590      <xref linkend="guc-datestyle"/> is set to <literal>ISO</literal>
591     </para>
592    </listitem>
593    <listitem>
594     <para>
595      <xref linkend="guc-intervalstyle"/> is set to <literal>postgres</literal>
596     </para>
597    </listitem>
598    <listitem>
599     <para>
600      <xref linkend="guc-extra-float-digits"/> is set to <literal>3</literal> for remote
601      servers 9.0 and newer and is set to <literal>2</literal> for older versions
602     </para>
603    </listitem>
604   </itemizedlist>
605   These are less likely to be problematic than <varname>search_path</varname>, but
606   can be handled with function <literal>SET</literal> options if the need arises.
607  </para>
608
609  <para>
610   It is <emphasis>not</emphasis> recommended that you override this behavior by
611   changing the session-level settings of these parameters; that is likely
612   to cause <filename>postgres_fdw</filename> to malfunction.
613  </para>
614 </sect2>
615
616 <sect2>
617  <title>Cross-Version Compatibility</title>
618
619  <para>
620   <filename>postgres_fdw</filename> can be used with remote servers dating back
621   to <productname>PostgreSQL</productname> 8.3.  Read-only capability is available
622   back to 8.1.  A limitation however is that <filename>postgres_fdw</filename>
623   generally assumes that immutable built-in functions and operators are
624   safe to send to the remote server for execution, if they appear in a
625   <literal>WHERE</literal> clause for a foreign table.  Thus, a built-in
626   function that was added since the remote server's release might be sent
627   to it for execution, resulting in <quote>function does not exist</quote> or
628   a similar error.  This type of failure can be worked around by
629   rewriting the query, for example by embedding the foreign table
630   reference in a sub-<literal>SELECT</literal> with <literal>OFFSET 0</literal> as an
631   optimization fence, and placing the problematic function or operator
632   outside the sub-<literal>SELECT</literal>.
633  </para>
634 </sect2>
635
636 <sect2>
637  <title>Examples</title>
638
639  <para>
640   Here is an example of creating a foreign table with
641   <literal>postgres_fdw</literal>. First install the extension:
642  </para>
643
644<programlisting>
645CREATE EXTENSION postgres_fdw;
646</programlisting>
647
648  <para>
649   Then create a foreign server using <xref linkend="sql-createserver"/>.
650   In this example we wish to connect to a <productname>PostgreSQL</productname> server
651   on host <literal>192.83.123.89</literal> listening on
652   port <literal>5432</literal>.  The database to which the connection is made
653   is named <literal>foreign_db</literal> on the remote server:
654
655<programlisting>
656CREATE SERVER foreign_server
657        FOREIGN DATA WRAPPER postgres_fdw
658        OPTIONS (host '192.83.123.89', port '5432', dbname 'foreign_db');
659</programlisting>
660  </para>
661
662  <para>
663   A user mapping, defined with <xref linkend="sql-createusermapping"/>, is
664   needed as well to identify the role that will be used on the remote
665   server:
666
667<programlisting>
668CREATE USER MAPPING FOR local_user
669        SERVER foreign_server
670        OPTIONS (user 'foreign_user', password 'password');
671</programlisting>
672  </para>
673
674  <para>
675   Now it is possible to create a foreign table with
676   <xref linkend="sql-createforeigntable"/>.  In this example we
677   wish to access the table named <structname>some_schema.some_table</structname>
678   on the remote server.  The local name for it will
679   be <structname>foreign_table</structname>:
680
681<programlisting>
682CREATE FOREIGN TABLE foreign_table (
683        id integer NOT NULL,
684        data text
685)
686        SERVER foreign_server
687        OPTIONS (schema_name 'some_schema', table_name 'some_table');
688</programlisting>
689
690   It's essential that the data types and other properties of the columns
691   declared in <command>CREATE FOREIGN TABLE</command> match the actual remote table.
692   Column names must match as well, unless you attach <literal>column_name</literal>
693   options to the individual columns to show how they are named in the remote
694   table.
695   In many cases, use of <xref linkend="sql-importforeignschema"/> is
696   preferable to constructing foreign table definitions manually.
697  </para>
698 </sect2>
699
700 <sect2>
701  <title>Author</title>
702  <para>
703   Shigeru Hanada <email>shigeru.hanada@gmail.com</email>
704  </para>
705 </sect2>
706
707</sect1>
708