@@ -61,7 +61,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
61
61
{ NOT NULL |
62
62
NULL |
63
63
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 }
65
66
66
67
<phrase>and <replaceable class="parameter">table_constraint</replaceable> is:</phrase>
67
68
@@ -94,7 +95,8 @@ CREATE FOREIGN TABLE [ IF NOT EXISTS ] <replaceable class="parameter">table_name
94
95
{ NOT NULL |
95
96
NULL |
96
97
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 }
98
100
99
101
<phrase>而 <replaceable class="parameter">table_constraint</replaceable> 是:</phrase>
100
102
@@ -261,7 +263,7 @@ ____________________________________________________________________________-->
261
263
</para>
262
264
</listitem>
263
265
</varlistentry>
264
-
266
+
265
267
<varlistentry>
266
268
<!--==========================orignal english content==========================
267
269
<term><literal>COLLATE <replaceable>collation</replaceable></literal></term>
@@ -306,6 +308,34 @@ ____________________________________________________________________________-->
306
308
</listitem>
307
309
</varlistentry>
308
310
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
+
309
339
<varlistentry>
310
340
<!--==========================orignal english content==========================
311
341
<term><literal>CONSTRAINT <replaceable class="parameter">constraint_name</replaceable></literal></term>
@@ -376,7 +406,7 @@ ____________________________________________________________________________-->
376
406
</para>
377
407
</listitem>
378
408
</varlistentry>
379
-
409
+
380
410
<varlistentry>
381
411
<!--==========================orignal english content==========================
382
412
<term><literal>CHECK ( <replaceable class="parameter">expression</replaceable> ) [ NO INHERIT ] </literal></term>
@@ -466,6 +496,52 @@ ____________________________________________________________________________-->
466
496
</listitem>
467
497
</varlistentry>
468
498
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
+
469
545
<varlistentry>
470
546
<!--==========================orignal english content==========================
471
547
<term><replaceable class="parameter">server_name</replaceable></term>
@@ -515,7 +591,7 @@ ____________________________________________________________________________-->
515
591
</variablelist>
516
592
517
593
</refsect1>
518
-
594
+
519
595
<refsect1>
520
596
<!--==========================orignal english content==========================
521
597
<title>Notes</title>
@@ -577,6 +653,37 @@ ____________________________________________________________________________-->
577
653
满足约束的行可见,在该表上的查询可能会产生不正确的回答。确保
578
654
约束定义符合实际是用户的责任。
579
655
</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>
580
687
</refsect1>
581
688
582
689
<refsect1 id="sql-createforeigntable-examples">
0 commit comments