Skip to content

Commit eb4c7ec

Browse files
authored
Merge pull request #284 from jingsam/create_foreign_table
fix ref/create_foreign_table.sgml
2 parents 433b002 + 74b6b40 commit eb4c7ec

File tree

1 file changed

+112
-5
lines changed

1 file changed

+112
-5
lines changed

postgresql/doc/src/sgml/ref/create_foreign_table.sgml

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
6161
{ NOT NULL |
6262
NULL |
6363
CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ] |
64-
DEFAULT <replaceable>default_expr</replaceable> }
64+
DEFAULT <replaceable>default_expr</replaceable> |
65+
GENERATED ALWAYS AS ( <replaceable>generation_expr</replaceable> ) STORED }
6566

6667
<phrase>and <replaceable class="parameter">table_constraint</replaceable> is:</phrase>
6768

@@ -94,7 +95,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
9495
{ NOT NULL |
9596
NULL |
9697
CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ] |
97-
DEFAULT <replaceable>default_expr</replaceable> }
98+
DEFAULT <replaceable>default_expr</replaceable> |
99+
GENERATED ALWAYS AS ( <replaceable>generation_expr</replaceable> ) STORED }
98100

99101
<phrase>而 <replaceable class="parameter">table_constraint</replaceable> 是:</phrase>
100102

@@ -261,7 +263,7 @@ ____________________________________________________________________________-->
261263
</para>
262264
</listitem>
263265
</varlistentry>
264-
266+
265267
<varlistentry>
266268
<!--==========================orignal english content==========================
267269
<term><literal>COLLATE <replaceable>collation</replaceable></literal></term>
@@ -306,6 +308,34 @@ ____________________________________________________________________________-->
306308
</listitem>
307309
</varlistentry>
308310

311+
<varlistentry>
312+
<!--==========================orignal english content==========================
313+
<term><literal>PARTITION OF <replaceable>parent_table</replaceable> FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable></literal></term>
314+
____________________________________________________________________________-->
315+
<term><literal>PARTITION OF <replaceable>parent_table</replaceable> FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable></literal></term>
316+
<listitem>
317+
<!--==========================orignal english content==========================
318+
<para>
319+
This form can be used to create the foreign table as partition of
320+
the given parent table with specified partition bound values.
321+
See the similar form of
322+
<xref linkend="sql-createtable"/> for more details.
323+
Note that it is currently not allowed to create the foreign table as a
324+
partition of the parent table if there are <literal>UNIQUE</literal>
325+
indexes on the parent table. (See also
326+
<link linkend="sql-altertable"><command>ALTER TABLE ATTACH PARTITION</command></link>.)
327+
</para>
328+
____________________________________________________________________________-->
329+
<para>
330+
此语句可以用来将外部表创建为父表的一个指定区间的分区表。
331+
详见<xref linkend="sql-createtable"/>的类似形式。
332+
注意如果父表存在<literal>UNIQUE</literal>类型的索引时,当前是不允许将外部表
333+
创建为该父表的分区表。(另见<link linkend="sql-altertable">
334+
<command>ALTER TABLE ATTACH PARTITION</command></link>。)
335+
</para>
336+
</listitem>
337+
</varlistentry>
338+
309339
<varlistentry>
310340
<!--==========================orignal english content==========================
311341
<term><literal>CONSTRAINT <replaceable class="parameter">constraint_name</replaceable></literal></term>
@@ -376,7 +406,7 @@ ____________________________________________________________________________-->
376406
</para>
377407
</listitem>
378408
</varlistentry>
379-
409+
380410
<varlistentry>
381411
<!--==========================orignal english content==========================
382412
<term><literal>CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ] </literal></term>
@@ -466,6 +496,52 @@ ____________________________________________________________________________-->
466496
</listitem>
467497
</varlistentry>
468498

499+
<varlistentry>
500+
<!--==========================orignal english content==========================
501+
<term><literal>GENERATED ALWAYS AS ( <replaceable>generation_expr</replaceable> ) STORED</literal><indexterm><primary>generated column</primary></indexterm></term>
502+
____________________________________________________________________________-->
503+
<term><literal>GENERATED ALWAYS AS ( <replaceable>generation_expr</replaceable> ) STORED</literal><indexterm><primary>generated column</primary></indexterm></term>
504+
<listitem>
505+
<!--==========================orignal english content==========================
506+
<para>
507+
This clause creates the column as a <firstterm>generated
508+
column</firstterm>. The column cannot be written to, and when read the
509+
result of the specified expression will be returned.
510+
</para>
511+
____________________________________________________________________________-->
512+
<para>
513+
该子句创建一个<firstterm>衍生列</firstterm>。
514+
此列不能写入,只能在读取时返回所指定的表达式的值。
515+
</para>
516+
517+
<!--==========================orignal english content==========================
518+
<para>
519+
The keyword <literal>STORED</literal> is required to signify that the
520+
column will be computed on write. (The computed value will be presented
521+
to the foreign-data wrapper for storage and must be returned on
522+
reading.)
523+
</para>
524+
____________________________________________________________________________-->
525+
<para>
526+
关键字<literal>STORED</literal>是必须的,用来表明该列将在写入时计算。
527+
(计算出的值将会传递给外部数据封装器负责保存,并在读取时返回。)
528+
</para>
529+
530+
<!--==========================orignal english content==========================
531+
<para>
532+
The generation expression can refer to other columns in the table, but
533+
not other generated columns. Any functions and operators used must be
534+
immutable. References to other tables are not allowed.
535+
</para>
536+
____________________________________________________________________________-->
537+
<para>
538+
衍生表达式可以引用表中的其他列,但不能引用其他的衍生列。
539+
所使用的函数和操作符必须是不可变。
540+
不能引用其他表。
541+
</para>
542+
</listitem>
543+
</varlistentry>
544+
469545
<varlistentry>
470546
<!--==========================orignal english content==========================
471547
<term><replaceable class="parameter">server_name</replaceable></term>
@@ -515,7 +591,7 @@ ____________________________________________________________________________-->
515591
</variablelist>
516592

517593
</refsect1>
518-
594+
519595
<refsect1>
520596
<!--==========================orignal english content==========================
521597
<title>Notes</title>
@@ -577,6 +653,37 @@ ____________________________________________________________________________-->
577653
满足约束的行可见,在该表上的查询可能会产生不正确的回答。确保
578654
约束定义符合实际是用户的责任。
579655
</para>
656+
657+
<!--==========================orignal english content==========================
658+
<para>
659+
Similar considerations apply to generated columns. Stored generated
660+
columns are computed on insert or update on the local
661+
<productname>PostgreSQL</productname> server and handed to the
662+
foreign-data wrapper for writing out to the foreign data store, but it is
663+
not enforced that a query of the foreign table returns values for stored
664+
generated columns that are consistent with the generation expression.
665+
Again, this might result in incorrect query results.
666+
</para>
667+
____________________________________________________________________________-->
668+
<para>
669+
类似的要点也适用于衍生列。衍生列在本地<productname>PostgreSQL</productname>
670+
服务器发生插入或更新时进行计算,并将计算结果传递给外部数据封装器,由外部数据
671+
封装器负责把结果写到外部数据存储中,但是并不强制要求查询外部表时返回的衍生列
672+
的值一定是与衍生表达式一致。
673+
总而言之,此行为可能导致查询到不正确的结果。
674+
</para>
675+
676+
<!--==========================orignal english content==========================
677+
<para>
678+
While rows can be moved from local partitions to a foreign-table partition
679+
(provided the foreign data wrapper supports tuple routing), they cannot be
680+
moved from a foreign-table partition to another partition.
681+
</para>
682+
____________________________________________________________________________-->
683+
<para>
684+
虽然列可以从本地分区移到外部表分区(使用的外部数据封装器支持元组路由),但是
685+
不能将列从外部表分区移动到本地分区。
686+
</para>
580687
</refsect1>
581688

582689
<refsect1 id="sql-createforeigntable-examples">

0 commit comments

Comments
 (0)