satisfy the
partitioning rule. Again, it is the user's responsibility to ensure
that that is true, which is best done by installing a matching
constraint on the remote server.
</para>
</caution>
<para>
Within a partitioned table containing foreign-table partitions,
an <command>UPDATE</command> that changes the partition key value can
cause a row to be moved from a local partition to a foreign-table
partition, provided the foreign data wrapper supports tuple routing.
However, it is not currently possible to move a row from a
foreign-table partition to another partition.
An <command>UPDATE</command> that would require doing that will fail
due to the partitioning constraint, assuming that that is properly
enforced by the remote server.
</para>
<para>
Similar considerations apply to generated columns. Stored generated
columns are computed on insert or update on the local
<productname>PostgreSQL</productname> server and handed to the
foreign-data wrapper for writing out to the foreign data store, but it is
not enforced that a query of the foreign table returns values for stored
generated columns that are consistent with the generation expression.
Again, this might result in incorrect query results.
</para>
</refsect1>
<refsect1 id="sql-createforeigntable-examples">
<title>Examples</title>
<para>
Create foreign table <structname>films</structname>, which will be accessed through
the server <structname>film_server</structname>:
<programlisting>
CREATE FOREIGN TABLE films (
code char(5) NOT NULL,
title varchar(40) NOT NULL,
did integer NOT NULL,
date_prod date,
kind varchar(10),
len interval hour to minute
)
SERVER film_server;
</programlisting></para>
<para>
Create foreign table <structname>measurement_y2016m07</structname>, which will be
accessed through the server <structname>server_07</structname>, as a partition
of the range partitioned table <structname>measurement</structname>:
<programlisting>
CREATE FOREIGN TABLE measurement_y2016m07
PARTITION OF measurement FOR VALUES FROM ('2016-07-01') TO ('2016-08-01')
SERVER server_07;
</programlisting></para>
</refsect1>
<refsect1 id="sql-createforeigntable-compatibility">
<title>Compatibility</title>
<para>
The <command>CREATE FOREIGN TABLE</command> command largely conforms to the
<acronym>SQL</acronym> standard; however, much as with
<link linkend="sql-createtable"><command>CREATE TABLE</command></link>,
<literal>NULL</literal> constraints and zero-column foreign tables are permitted.
The ability to specify column default values is also
a <productname>PostgreSQL</productname> extension. Table inheritance, in the form
defined by <productname>PostgreSQL</productname>, is nonstandard.
The <literal>LIKE</literal> clause, as supported in this command, is
nonstandard.
</para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="sql-alterforeigntable"/></member>
<member><xref linkend="sql-dropforeigntable"/></member>
<member><xref linkend="sql-createtable"/></member>
<member><xref linkend="sql-createserver"/></member>
<member><xref linkend="sql-importforeignschema"/></member>
</simplelist>
</refsect1>
</refentry>