You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<phrase><replaceable class="PARAMETER">index_parameters</replaceable> in <literal>UNIQUE</literal>, <literal>PRIMARY KEY</literal>, and <literal>EXCLUDE</literal> constraints are:</phrase>
92
92
@@ -261,10 +261,48 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
261
261
any existing partition of that parent.
262
262
</para>
263
263
264
+
<note>
265
+
<para>
266
+
Each of the values specified in the partition bound specification is
267
+
a literal, <literal>NULL</literal>, or <literal>UNBOUNDED</literal>.
268
+
A literal is either a numeric constant or a string constant that is
269
+
coercable to the corresponding partition key column's type.
270
+
</para>
271
+
272
+
<para>
273
+
When creating a range partition, the lower bound specified with
274
+
<literal>FROM</literal> is an inclusive bound, whereas the upper bound
275
+
specified with <literal>TO</literal> is an exclusive bound. That is,
276
+
the values specified in the <literal>FROM</literal> list are accepted
277
+
values of the corresponding partition key columns in a given partition,
278
+
whereas those in the <literal>TO</literal> list are not. To be precise,
279
+
this applies only to the first of the partition key columns for which
280
+
the corresponding values in the <literal>FROM</literal> and
281
+
<literal>TO</literal> lists are not equal. All rows in a given
282
+
partition contain the same values for all preceding columns, equal to
283
+
those specified in <literal>FROM</literal> and <literal>TO</literal>
284
+
lists. On the other hand, any subsequent columns are insignificant
285
+
as far as implicit partition constraint is concerned.
286
+
287
+
Specifying <literal>UNBOUNDED</literal> in <literal>FROM</literal>
288
+
signifies <literal>-infinity</literal> as the lower bound of the
289
+
corresponding column, whereas it signifies <literal>+infinity</literal>
290
+
as the upper bound when specified in <literal>TO</literal>.
291
+
</para>
292
+
293
+
<para>
294
+
When creating a list partition, <literal>NULL</literal> can be specified
295
+
to signify that the partition allows the partition key column to be null.
296
+
However, there cannot be more than one such list partitions for a given
297
+
parent table. <literal>NULL</literal> cannot specified for range
298
+
partitions.
299
+
</para>
300
+
</note>
301
+
264
302
<para>
265
303
A partition cannot have columns other than those inherited from the
266
-
parent. That includes the <structfield>oid</> column, which can be
267
-
specified using the <literal>WITH (OIDS)</literal> clause.
304
+
parent. If the parent is specified <literal>WITH OIDS</literal> then
305
+
the partitions must also explicitly specify <literal>WITH OIDS</literal>.
268
306
Defaults and constraints can optionally be specified for each of the
269
307
inherited columns. One can also specify table constraints in addition
270
308
to those inherited from the parent. If a check constraint with the name
@@ -386,11 +424,12 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
386
424
<firstterm>partitioned</firstterm> table. The parenthesized list of
387
425
columns or expressions forms the <firstterm>partition key</firstterm>
388
426
for the table. When using range partitioning, the partition key can
389
-
include multiple columns or expressions, but for list partitioning, the
390
-
partition key must consist of a single column or expression. If no
391
-
btree operator class is specified when creating a partitioned table,
392
-
the default btree operator class for the datatype will be used. If
393
-
there is none, an error will be reported.
427
+
include multiple columns or expressions (up to 32, but this limit can
428
+
altered when building <productname>PostgreSQL</productname>.), but for
429
+
list partitioning, the partition key must consist of a single column or
430
+
expression. If no btree operator class is specified when creating a
431
+
partitioned table, the default btree operator class for the datatype will
432
+
be used. If there is none, an error will be reported.
394
433
</para>
395
434
396
435
<para>
@@ -1482,6 +1521,16 @@ CREATE TABLE measurement (
1482
1521
peaktemp int,
1483
1522
unitsales int
1484
1523
) PARTITION BY RANGE (logdate);
1524
+
</programlisting></para>
1525
+
1526
+
<para>
1527
+
Create a range partitioned table with multiple columns in the partition key:
1528
+
<programlisting>
1529
+
CREATE TABLE measurement_year_month (
1530
+
logdate date not null,
1531
+
peaktemp int,
1532
+
unitsales int
1533
+
) PARTITION BY RANGE (EXTRACT(YEAR FROM logdate), EXTRACT(MONTH FROM logdate));
0 commit comments