1CREATE TABLE(7) PostgreSQL 10.7 Documentation CREATE TABLE(7)
2
3
4
6 CREATE_TABLE - define a new table
7
9 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name ( [
10 { column_name data_type [ COLLATE collation ] [ column_constraint [ ... ] ]
11 | table_constraint
12 | LIKE source_table [ like_option ... ] }
13 [, ... ]
14 ] )
15 [ INHERITS ( parent_table [, ... ] ) ]
16 [ PARTITION BY { RANGE | LIST } ( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [, ... ] ) ]
17 [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
18 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
19 [ TABLESPACE tablespace_name ]
20
21 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name
22 OF type_name [ (
23 { column_name [ WITH OPTIONS ] [ column_constraint [ ... ] ]
24 | table_constraint }
25 [, ... ]
26 ) ]
27 [ PARTITION BY { RANGE | LIST } ( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [, ... ] ) ]
28 [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
29 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
30 [ TABLESPACE tablespace_name ]
31
32 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] table_name
33 PARTITION OF parent_table [ (
34 { column_name [ WITH OPTIONS ] [ column_constraint [ ... ] ]
35 | table_constraint }
36 [, ... ]
37 ) ] FOR VALUES partition_bound_spec
38 [ PARTITION BY { RANGE | LIST } ( { column_name | ( expression ) } [ COLLATE collation ] [ opclass ] [, ... ] ) ]
39 [ WITH ( storage_parameter [= value] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
40 [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
41 [ TABLESPACE tablespace_name ]
42
43 where column_constraint is:
44
45 [ CONSTRAINT constraint_name ]
46 { NOT NULL |
47 NULL |
48 CHECK ( expression ) [ NO INHERIT ] |
49 DEFAULT default_expr |
50 GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) ] |
51 UNIQUE index_parameters |
52 PRIMARY KEY index_parameters |
53 REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
54 [ ON DELETE action ] [ ON UPDATE action ] }
55 [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
56
57 and table_constraint is:
58
59 [ CONSTRAINT constraint_name ]
60 { CHECK ( expression ) [ NO INHERIT ] |
61 UNIQUE ( column_name [, ... ] ) index_parameters |
62 PRIMARY KEY ( column_name [, ... ] ) index_parameters |
63 EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [ WHERE ( predicate ) ] |
64 FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ]
65 [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE action ] [ ON UPDATE action ] }
66 [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
67
68 and like_option is:
69
70 { INCLUDING | EXCLUDING } { COMMENTS | CONSTRAINTS | DEFAULTS | IDENTITY | INDEXES | STATISTICS | STORAGE | ALL }
71
72 and partition_bound_spec is:
73
74 IN ( { numeric_literal | string_literal | TRUE | FALSE | NULL } [, ...] ) |
75 FROM ( { numeric_literal | string_literal | TRUE | FALSE | MINVALUE | MAXVALUE } [, ...] )
76 TO ( { numeric_literal | string_literal | TRUE | FALSE | MINVALUE | MAXVALUE } [, ...] )
77
78 index_parameters in UNIQUE, PRIMARY KEY, and EXCLUDE constraints are:
79
80 [ WITH ( storage_parameter [= value] [, ... ] ) ]
81 [ USING INDEX TABLESPACE tablespace_name ]
82
83 exclude_element in an EXCLUDE constraint is:
84
85 { column_name | ( expression ) } [ opclass ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ]
86
88 CREATE TABLE will create a new, initially empty table in the current
89 database. The table will be owned by the user issuing the command.
90
91 If a schema name is given (for example, CREATE TABLE myschema.mytable
92 ...) then the table is created in the specified schema. Otherwise it is
93 created in the current schema. Temporary tables exist in a special
94 schema, so a schema name cannot be given when creating a temporary
95 table. The name of the table must be distinct from the name of any
96 other table, sequence, index, view, or foreign table in the same
97 schema.
98
99 CREATE TABLE also automatically creates a data type that represents the
100 composite type corresponding to one row of the table. Therefore, tables
101 cannot have the same name as any existing data type in the same schema.
102
103 The optional constraint clauses specify constraints (tests) that new or
104 updated rows must satisfy for an insert or update operation to succeed.
105 A constraint is an SQL object that helps define the set of valid values
106 in the table in various ways.
107
108 There are two ways to define constraints: table constraints and column
109 constraints. A column constraint is defined as part of a column
110 definition. A table constraint definition is not tied to a particular
111 column, and it can encompass more than one column. Every column
112 constraint can also be written as a table constraint; a column
113 constraint is only a notational convenience for use when the constraint
114 only affects one column.
115
116 To be able to create a table, you must have USAGE privilege on all
117 column types or the type in the OF clause, respectively.
118
120 TEMPORARY or TEMP
121 If specified, the table is created as a temporary table. Temporary
122 tables are automatically dropped at the end of a session, or
123 optionally at the end of the current transaction (see ON COMMIT
124 below). Existing permanent tables with the same name are not
125 visible to the current session while the temporary table exists,
126 unless they are referenced with schema-qualified names. Any indexes
127 created on a temporary table are automatically temporary as well.
128
129 The autovacuum daemon cannot access and therefore cannot vacuum or
130 analyze temporary tables. For this reason, appropriate vacuum and
131 analyze operations should be performed via session SQL commands.
132 For example, if a temporary table is going to be used in complex
133 queries, it is wise to run ANALYZE on the temporary table after it
134 is populated.
135
136 Optionally, GLOBAL or LOCAL can be written before TEMPORARY or
137 TEMP. This presently makes no difference in PostgreSQL and is
138 deprecated; see COMPATIBILITY.
139
140 UNLOGGED
141 If specified, the table is created as an unlogged table. Data
142 written to unlogged tables is not written to the write-ahead log
143 (see Chapter 30), which makes them considerably faster than
144 ordinary tables. However, they are not crash-safe: an unlogged
145 table is automatically truncated after a crash or unclean shutdown.
146 The contents of an unlogged table are also not replicated to
147 standby servers. Any indexes created on an unlogged table are
148 automatically unlogged as well.
149
150 IF NOT EXISTS
151 Do not throw an error if a relation with the same name already
152 exists. A notice is issued in this case. Note that there is no
153 guarantee that the existing relation is anything like the one that
154 would have been created.
155
156 table_name
157 The name (optionally schema-qualified) of the table to be created.
158
159 OF type_name
160 Creates a typed table, which takes its structure from the specified
161 composite type (name optionally schema-qualified). A typed table is
162 tied to its type; for example the table will be dropped if the type
163 is dropped (with DROP TYPE ... CASCADE).
164
165 When a typed table is created, then the data types of the columns
166 are determined by the underlying composite type and are not
167 specified by the CREATE TABLE command. But the CREATE TABLE command
168 can add defaults and constraints to the table and can specify
169 storage parameters.
170
171 PARTITION OF parent_table FOR VALUES partition_bound_spec
172 Creates the table as a partition of the specified parent table.
173
174 The partition_bound_spec must correspond to the partitioning method
175 and partition key of the parent table, and must not overlap with
176 any existing partition of that parent. The form with IN is used for
177 list partitioning, while the form with FROM and TO is used for
178 range partitioning.
179
180 Each of the values specified in the partition_bound_spec is a
181 literal, NULL, MINVALUE, or MAXVALUE. Each literal value must be
182 either a numeric constant that is coercible to the corresponding
183 partition key column's type, or a string literal that is valid
184 input for that type.
185
186 When creating a list partition, NULL can be specified to signify
187 that the partition allows the partition key column to be null.
188 However, there cannot be more than one such list partition for a
189 given parent table. NULL cannot be specified for range partitions.
190
191 When creating a range partition, the lower bound specified with
192 FROM is an inclusive bound, whereas the upper bound specified with
193 TO is an exclusive bound. That is, the values specified in the FROM
194 list are valid values of the corresponding partition key columns
195 for this partition, whereas those in the TO list are not. Note that
196 this statement must be understood according to the rules of
197 row-wise comparison (Section 9.23.5). For example, given PARTITION
198 BY RANGE (x,y), a partition bound FROM (1, 2) TO (3, 4) allows x=1
199 with any y>=2, x=2 with any non-null y, and x=3 with any y<4.
200
201 The special values MINVALUE and MAXVALUE may be used when creating
202 a range partition to indicate that there is no lower or upper bound
203 on the column's value. For example, a partition defined using FROM
204 (MINVALUE) TO (10) allows any values less than 10, and a partition
205 defined using FROM (10) TO (MAXVALUE) allows any values greater
206 than or equal to 10.
207
208 When creating a range partition involving more than one column, it
209 can also make sense to use MAXVALUE as part of the lower bound, and
210 MINVALUE as part of the upper bound. For example, a partition
211 defined using FROM (0, MAXVALUE) TO (10, MAXVALUE) allows any rows
212 where the first partition key column is greater than 0 and less
213 than or equal to 10. Similarly, a partition defined using FROM
214 ('a', MINVALUE) TO ('b', MINVALUE) allows any rows where the first
215 partition key column starts with "a".
216
217 Note that if MINVALUE or MAXVALUE is used for one column of a
218 partitioning bound, the same value must be used for all subsequent
219 columns. For example, (10, MINVALUE, 0) is not a valid bound; you
220 should write (10, MINVALUE, MINVALUE).
221
222 Also note that some element types, such as timestamp, have a notion
223 of "infinity", which is just another value that can be stored. This
224 is different from MINVALUE and MAXVALUE, which are not real values
225 that can be stored, but rather they are ways of saying that the
226 value is unbounded. MAXVALUE can be thought of as being greater
227 than any other value, including "infinity" and MINVALUE as being
228 less than any other value, including "minus infinity". Thus the
229 range FROM ('infinity') TO (MAXVALUE) is not an empty range; it
230 allows precisely one value to be stored — "infinity".
231
232 A partition must have the same column names and types as the
233 partitioned table to which it belongs. If the parent is specified
234 WITH OIDS then all partitions must have OIDs; the parent's OID
235 column will be inherited by all partitions just like any other
236 column. Modifications to the column names or types of a partitioned
237 table, or the addition or removal of an OID column, will
238 automatically propagate to all partitions. CHECK constraints will
239 be inherited automatically by every partition, but an individual
240 partition may specify additional CHECK constraints; additional
241 constraints with the same name and condition as in the parent will
242 be merged with the parent constraint. Defaults may be specified
243 separately for each partition.
244
245 Rows inserted into a partitioned table will be automatically routed
246 to the correct partition. If no suitable partition exists, an error
247 will occur. Also, if updating a row in a given partition would
248 require it to move to another partition due to new partition key
249 values, an error will occur.
250
251 Operations such as TRUNCATE which normally affect a table and all
252 of its inheritance children will cascade to all partitions, but may
253 also be performed on an individual partition. Note that dropping a
254 partition with DROP TABLE requires taking an ACCESS EXCLUSIVE lock
255 on the parent table.
256
257 column_name
258 The name of a column to be created in the new table.
259
260 data_type
261 The data type of the column. This can include array specifiers. For
262 more information on the data types supported by PostgreSQL, refer
263 to Chapter 8.
264
265 COLLATE collation
266 The COLLATE clause assigns a collation to the column (which must be
267 of a collatable data type). If not specified, the column data
268 type's default collation is used.
269
270 INHERITS ( parent_table [, ... ] )
271 The optional INHERITS clause specifies a list of tables from which
272 the new table automatically inherits all columns. Parent tables can
273 be plain tables or foreign tables.
274
275 Use of INHERITS creates a persistent relationship between the new
276 child table and its parent table(s). Schema modifications to the
277 parent(s) normally propagate to children as well, and by default
278 the data of the child table is included in scans of the parent(s).
279
280 If the same column name exists in more than one parent table, an
281 error is reported unless the data types of the columns match in
282 each of the parent tables. If there is no conflict, then the
283 duplicate columns are merged to form a single column in the new
284 table. If the column name list of the new table contains a column
285 name that is also inherited, the data type must likewise match the
286 inherited column(s), and the column definitions are merged into
287 one. If the new table explicitly specifies a default value for the
288 column, this default overrides any defaults from inherited
289 declarations of the column. Otherwise, any parents that specify
290 default values for the column must all specify the same default, or
291 an error will be reported.
292
293 CHECK constraints are merged in essentially the same way as
294 columns: if multiple parent tables and/or the new table definition
295 contain identically-named CHECK constraints, these constraints must
296 all have the same check expression, or an error will be reported.
297 Constraints having the same name and expression will be merged into
298 one copy. A constraint marked NO INHERIT in a parent will not be
299 considered. Notice that an unnamed CHECK constraint in the new
300 table will never be merged, since a unique name will always be
301 chosen for it.
302
303 Column STORAGE settings are also copied from parent tables.
304
305 If a column in the parent table is an identity column, that
306 property is not inherited. A column in the child table can be
307 declared identity column if desired.
308
309 PARTITION BY { RANGE | LIST } ( { column_name | ( expression ) } [
310 opclass ] [, ...] )
311 The optional PARTITION BY clause specifies a strategy of
312 partitioning the table. The table thus created is called a
313 partitioned table. The parenthesized list of columns or expressions
314 forms the partition key for the table. When using range
315 partitioning, the partition key can include multiple columns or
316 expressions (up to 32, but this limit can be altered when building
317 PostgreSQL), but for list partitioning, the partition key must
318 consist of a single column or expression. If no B-tree operator
319 class is specified when creating a partitioned table, the default
320 B-tree operator class for the datatype will be used. If there is
321 none, an error will be reported.
322
323 A partitioned table is divided into sub-tables (called partitions),
324 which are created using separate CREATE TABLE commands. The
325 partitioned table is itself empty. A data row inserted into the
326 table is routed to a partition based on the value of columns or
327 expressions in the partition key. If no existing partition matches
328 the values in the new row, an error will be reported.
329
330 Partitioned tables do not support UNIQUE, PRIMARY KEY, EXCLUDE, or
331 FOREIGN KEY constraints; however, you can define these constraints
332 on individual partitions.
333
334 LIKE source_table [ like_option ... ]
335 The LIKE clause specifies a table from which the new table
336 automatically copies all column names, their data types, and their
337 not-null constraints.
338
339 Unlike INHERITS, the new table and original table are completely
340 decoupled after creation is complete. Changes to the original table
341 will not be applied to the new table, and it is not possible to
342 include data of the new table in scans of the original table.
343
344 Default expressions for the copied column definitions will be
345 copied only if INCLUDING DEFAULTS is specified. The default
346 behavior is to exclude default expressions, resulting in the copied
347 columns in the new table having null defaults. Note that copying
348 defaults that call database-modification functions, such as
349 nextval, may create a functional linkage between the original and
350 new tables.
351
352 Any identity specifications of copied column definitions will only
353 be copied if INCLUDING IDENTITY is specified. A new sequence is
354 created for each identity column of the new table, separate from
355 the sequences associated with the old table.
356
357 Not-null constraints are always copied to the new table. CHECK
358 constraints will be copied only if INCLUDING CONSTRAINTS is
359 specified. No distinction is made between column constraints and
360 table constraints.
361
362 Extended statistics are copied to the new table if INCLUDING
363 STATISTICS is specified.
364
365 Indexes, PRIMARY KEY, UNIQUE, and EXCLUDE constraints on the
366 original table will be created on the new table only if INCLUDING
367 INDEXES is specified. Names for the new indexes and constraints are
368 chosen according to the default rules, regardless of how the
369 originals were named. (This behavior avoids possible duplicate-name
370 failures for the new indexes.)
371
372 STORAGE settings for the copied column definitions will be copied
373 only if INCLUDING STORAGE is specified. The default behavior is to
374 exclude STORAGE settings, resulting in the copied columns in the
375 new table having type-specific default settings. For more on
376 STORAGE settings, see Section 66.2.
377
378 Comments for the copied columns, constraints, and indexes will be
379 copied only if INCLUDING COMMENTS is specified. The default
380 behavior is to exclude comments, resulting in the copied columns
381 and constraints in the new table having no comments.
382
383 INCLUDING ALL is an abbreviated form of INCLUDING COMMENTS
384 INCLUDING CONSTRAINTS INCLUDING DEFAULTS INCLUDING IDENTITY
385 INCLUDING INDEXES INCLUDING STATISTICS INCLUDING STORAGE.
386
387 Note that unlike INHERITS, columns and constraints copied by LIKE
388 are not merged with similarly named columns and constraints. If the
389 same name is specified explicitly or in another LIKE clause, an
390 error is signaled.
391
392 The LIKE clause can also be used to copy column definitions from
393 views, foreign tables, or composite types. Inapplicable options
394 (e.g., INCLUDING INDEXES from a view) are ignored.
395
396 CONSTRAINT constraint_name
397 An optional name for a column or table constraint. If the
398 constraint is violated, the constraint name is present in error
399 messages, so constraint names like col must be positive can be used
400 to communicate helpful constraint information to client
401 applications. (Double-quotes are needed to specify constraint names
402 that contain spaces.) If a constraint name is not specified, the
403 system generates a name.
404
405 NOT NULL
406 The column is not allowed to contain null values.
407
408 NULL
409 The column is allowed to contain null values. This is the default.
410
411 This clause is only provided for compatibility with non-standard
412 SQL databases. Its use is discouraged in new applications.
413
414 CHECK ( expression ) [ NO INHERIT ]
415 The CHECK clause specifies an expression producing a Boolean result
416 which new or updated rows must satisfy for an insert or update
417 operation to succeed. Expressions evaluating to TRUE or UNKNOWN
418 succeed. Should any row of an insert or update operation produce a
419 FALSE result, an error exception is raised and the insert or update
420 does not alter the database. A check constraint specified as a
421 column constraint should reference that column's value only, while
422 an expression appearing in a table constraint can reference
423 multiple columns.
424
425 Currently, CHECK expressions cannot contain subqueries nor refer to
426 variables other than columns of the current row. The system column
427 tableoid may be referenced, but not any other system column.
428
429 A constraint marked with NO INHERIT will not propagate to child
430 tables.
431
432 When a table has multiple CHECK constraints, they will be tested
433 for each row in alphabetical order by name, after checking NOT NULL
434 constraints. (PostgreSQL versions before 9.5 did not honor any
435 particular firing order for CHECK constraints.)
436
437 DEFAULT default_expr
438 The DEFAULT clause assigns a default data value for the column
439 whose column definition it appears within. The value is any
440 variable-free expression (subqueries and cross-references to other
441 columns in the current table are not allowed). The data type of the
442 default expression must match the data type of the column.
443
444 The default expression will be used in any insert operation that
445 does not specify a value for the column. If there is no default for
446 a column, then the default is null.
447
448 GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( sequence_options ) ]
449 This clause creates the column as an identity column. It will have
450 an implicit sequence attached to it and the column in new rows will
451 automatically have values from the sequence assigned to it.
452
453 The clauses ALWAYS and BY DEFAULT determine how the sequence value
454 is given precedence over a user-specified value in an INSERT
455 statement. If ALWAYS is specified, a user-specified value is only
456 accepted if the INSERT statement specifies OVERRIDING SYSTEM VALUE.
457 If BY DEFAULT is specified, then the user-specified value takes
458 precedence. See INSERT(7) for details. (In the COPY command,
459 user-specified values are always used regardless of this setting.)
460
461 The optional sequence_options clause can be used to override the
462 options of the sequence. See CREATE SEQUENCE (CREATE_SEQUENCE(7))
463 for details.
464
465 UNIQUE (column constraint)
466 UNIQUE ( column_name [, ... ] ) (table constraint)
467 The UNIQUE constraint specifies that a group of one or more columns
468 of a table can contain only unique values. The behavior of the
469 unique table constraint is the same as that for column constraints,
470 with the additional capability to span multiple columns.
471
472 For the purpose of a unique constraint, null values are not
473 considered equal.
474
475 Each unique table constraint must name a set of columns that is
476 different from the set of columns named by any other unique or
477 primary key constraint defined for the table. (Otherwise it would
478 just be the same constraint listed twice.)
479
480 PRIMARY KEY (column constraint)
481 PRIMARY KEY ( column_name [, ... ] ) (table constraint)
482 The PRIMARY KEY constraint specifies that a column or columns of a
483 table can contain only unique (non-duplicate), nonnull values. Only
484 one primary key can be specified for a table, whether as a column
485 constraint or a table constraint.
486
487 The primary key constraint should name a set of columns that is
488 different from the set of columns named by any unique constraint
489 defined for the same table. (Otherwise, the unique constraint is
490 redundant and will be discarded.)
491
492 PRIMARY KEY enforces the same data constraints as a combination of
493 UNIQUE and NOT NULL, but identifying a set of columns as the
494 primary key also provides metadata about the design of the schema,
495 since a primary key implies that other tables can rely on this set
496 of columns as a unique identifier for rows.
497
498 EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ]
499 ) index_parameters [ WHERE ( predicate ) ]
500 The EXCLUDE clause defines an exclusion constraint, which
501 guarantees that if any two rows are compared on the specified
502 column(s) or expression(s) using the specified operator(s), not all
503 of these comparisons will return TRUE. If all of the specified
504 operators test for equality, this is equivalent to a UNIQUE
505 constraint, although an ordinary unique constraint will be faster.
506 However, exclusion constraints can specify constraints that are
507 more general than simple equality. For example, you can specify a
508 constraint that no two rows in the table contain overlapping
509 circles (see Section 8.8) by using the && operator.
510
511 Exclusion constraints are implemented using an index, so each
512 specified operator must be associated with an appropriate operator
513 class (see Section 11.9) for the index access method index_method.
514 The operators are required to be commutative. Each exclude_element
515 can optionally specify an operator class and/or ordering options;
516 these are described fully under CREATE INDEX (CREATE_INDEX(7)).
517
518 The access method must support amgettuple (see Chapter 60); at
519 present this means GIN cannot be used. Although it's allowed, there
520 is little point in using B-tree or hash indexes with an exclusion
521 constraint, because this does nothing that an ordinary unique
522 constraint doesn't do better. So in practice the access method will
523 always be GiST or SP-GiST.
524
525 The predicate allows you to specify an exclusion constraint on a
526 subset of the table; internally this creates a partial index. Note
527 that parentheses are required around the predicate.
528
529 REFERENCES reftable [ ( refcolumn ) ] [ MATCH matchtype ] [ ON DELETE
530 action ] [ ON UPDATE action ] (column constraint)
531 FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn
532 [, ... ] ) ] [ MATCH matchtype ] [ ON DELETE action ] [ ON UPDATE
533 action ] (table constraint)
534 These clauses specify a foreign key constraint, which requires that
535 a group of one or more columns of the new table must only contain
536 values that match values in the referenced column(s) of some row of
537 the referenced table. If the refcolumn list is omitted, the primary
538 key of the reftable is used. The referenced columns must be the
539 columns of a non-deferrable unique or primary key constraint in the
540 referenced table. The user must have REFERENCES permission on the
541 referenced table (either the whole table, or the specific
542 referenced columns). Note that foreign key constraints cannot be
543 defined between temporary tables and permanent tables.
544
545 A value inserted into the referencing column(s) is matched against
546 the values of the referenced table and referenced columns using the
547 given match type. There are three match types: MATCH FULL, MATCH
548 PARTIAL, and MATCH SIMPLE (which is the default). MATCH FULL will
549 not allow one column of a multicolumn foreign key to be null unless
550 all foreign key columns are null; if they are all null, the row is
551 not required to have a match in the referenced table. MATCH SIMPLE
552 allows any of the foreign key columns to be null; if any of them
553 are null, the row is not required to have a match in the referenced
554 table. MATCH PARTIAL is not yet implemented. (Of course, NOT NULL
555 constraints can be applied to the referencing column(s) to prevent
556 these cases from arising.)
557
558 In addition, when the data in the referenced columns is changed,
559 certain actions are performed on the data in this table's columns.
560 The ON DELETE clause specifies the action to perform when a
561 referenced row in the referenced table is being deleted. Likewise,
562 the ON UPDATE clause specifies the action to perform when a
563 referenced column in the referenced table is being updated to a new
564 value. If the row is updated, but the referenced column is not
565 actually changed, no action is done. Referential actions other than
566 the NO ACTION check cannot be deferred, even if the constraint is
567 declared deferrable. There are the following possible actions for
568 each clause:
569
570 NO ACTION
571 Produce an error indicating that the deletion or update would
572 create a foreign key constraint violation. If the constraint is
573 deferred, this error will be produced at constraint check time
574 if there still exist any referencing rows. This is the default
575 action.
576
577 RESTRICT
578 Produce an error indicating that the deletion or update would
579 create a foreign key constraint violation. This is the same as
580 NO ACTION except that the check is not deferrable.
581
582 CASCADE
583 Delete any rows referencing the deleted row, or update the
584 values of the referencing column(s) to the new values of the
585 referenced columns, respectively.
586
587 SET NULL
588 Set the referencing column(s) to null.
589
590 SET DEFAULT
591 Set the referencing column(s) to their default values. (There
592 must be a row in the referenced table matching the default
593 values, if they are not null, or the operation will fail.)
594
595 If the referenced column(s) are changed frequently, it might be
596 wise to add an index to the referencing column(s) so that
597 referential actions associated with the foreign key constraint can
598 be performed more efficiently.
599
600 DEFERRABLE
601 NOT DEFERRABLE
602 This controls whether the constraint can be deferred. A constraint
603 that is not deferrable will be checked immediately after every
604 command. Checking of constraints that are deferrable can be
605 postponed until the end of the transaction (using the SET
606 CONSTRAINTS (SET_CONSTRAINTS(7)) command). NOT DEFERRABLE is the
607 default. Currently, only UNIQUE, PRIMARY KEY, EXCLUDE, and
608 REFERENCES (foreign key) constraints accept this clause. NOT NULL
609 and CHECK constraints are not deferrable. Note that deferrable
610 constraints cannot be used as conflict arbitrators in an INSERT
611 statement that includes an ON CONFLICT DO UPDATE clause.
612
613 INITIALLY IMMEDIATE
614 INITIALLY DEFERRED
615 If a constraint is deferrable, this clause specifies the default
616 time to check the constraint. If the constraint is INITIALLY
617 IMMEDIATE, it is checked after each statement. This is the default.
618 If the constraint is INITIALLY DEFERRED, it is checked only at the
619 end of the transaction. The constraint check time can be altered
620 with the SET CONSTRAINTS (SET_CONSTRAINTS(7)) command.
621
622 WITH ( storage_parameter [= value] [, ... ] )
623 This clause specifies optional storage parameters for a table or
624 index; see Storage Parameters for more information. The WITH clause
625 for a table can also include OIDS=TRUE (or just OIDS) to specify
626 that rows of the new table should have OIDs (object identifiers)
627 assigned to them, or OIDS=FALSE to specify that the rows should not
628 have OIDs. If OIDS is not specified, the default setting depends
629 upon the default_with_oids configuration parameter. (If the new
630 table inherits from any tables that have OIDs, then OIDS=TRUE is
631 forced even if the command says OIDS=FALSE.)
632
633 If OIDS=FALSE is specified or implied, the new table does not store
634 OIDs and no OID will be assigned for a row inserted into it. This
635 is generally considered worthwhile, since it will reduce OID
636 consumption and thereby postpone the wraparound of the 32-bit OID
637 counter. Once the counter wraps around, OIDs can no longer be
638 assumed to be unique, which makes them considerably less useful. In
639 addition, excluding OIDs from a table reduces the space required to
640 store the table on disk by 4 bytes per row (on most machines),
641 slightly improving performance.
642
643 To remove OIDs from a table after it has been created, use ALTER
644 TABLE (ALTER_TABLE(7)).
645
646 WITH OIDS
647 WITHOUT OIDS
648 These are obsolescent syntaxes equivalent to WITH (OIDS) and WITH
649 (OIDS=FALSE), respectively. If you wish to give both an OIDS
650 setting and storage parameters, you must use the WITH ( ... )
651 syntax; see above.
652
653 ON COMMIT
654 The behavior of temporary tables at the end of a transaction block
655 can be controlled using ON COMMIT. The three options are:
656
657 PRESERVE ROWS
658 No special action is taken at the ends of transactions. This is
659 the default behavior.
660
661 DELETE ROWS
662 All rows in the temporary table will be deleted at the end of
663 each transaction block. Essentially, an automatic TRUNCATE(7)
664 is done at each commit. When used on a partitioned table, this
665 is not cascaded to its partitions.
666
667 DROP
668 The temporary table will be dropped at the end of the current
669 transaction block. When used on a partitioned table, this
670 action drops its partitions and when used on tables with
671 inheritance children, it drops the dependent children.
672
673 TABLESPACE tablespace_name
674 The tablespace_name is the name of the tablespace in which the new
675 table is to be created. If not specified, default_tablespace is
676 consulted, or temp_tablespaces if the table is temporary.
677
678 USING INDEX TABLESPACE tablespace_name
679 This clause allows selection of the tablespace in which the index
680 associated with a UNIQUE, PRIMARY KEY, or EXCLUDE constraint will
681 be created. If not specified, default_tablespace is consulted, or
682 temp_tablespaces if the table is temporary.
683
684 Storage Parameters
685 The WITH clause can specify storage parameters for tables, and for
686 indexes associated with a UNIQUE, PRIMARY KEY, or EXCLUDE constraint.
687 Storage parameters for indexes are documented in CREATE INDEX
688 (CREATE_INDEX(7)). The storage parameters currently available for
689 tables are listed below. For many of these parameters, as shown, there
690 is an additional parameter with the same name prefixed with toast.,
691 which controls the behavior of the table's secondary TOAST table, if
692 any (see Section 66.2 for more information about TOAST). If a table
693 parameter value is set and the equivalent toast. parameter is not, the
694 TOAST table will use the table's parameter value. Specifying these
695 parameters for partitioned tables is not supported, but you may specify
696 them for individual leaf partitions.
697
698 fillfactor (integer)
699 The fillfactor for a table is a percentage between 10 and 100. 100
700 (complete packing) is the default. When a smaller fillfactor is
701 specified, INSERT operations pack table pages only to the indicated
702 percentage; the remaining space on each page is reserved for
703 updating rows on that page. This gives UPDATE a chance to place the
704 updated copy of a row on the same page as the original, which is
705 more efficient than placing it on a different page. For a table
706 whose entries are never updated, complete packing is the best
707 choice, but in heavily updated tables smaller fillfactors are
708 appropriate. This parameter cannot be set for TOAST tables.
709
710 parallel_workers (integer)
711 This sets the number of workers that should be used to assist a
712 parallel scan of this table. If not set, the system will determine
713 a value based on the relation size. The actual number of workers
714 chosen by the planner may be less, for example due to the setting
715 of max_worker_processes.
716
717 autovacuum_enabled, toast.autovacuum_enabled (boolean)
718 Enables or disables the autovacuum daemon for a particular table.
719 If true, the autovacuum daemon will perform automatic VACUUM and/or
720 ANALYZE operations on this table following the rules discussed in
721 Section 24.1.6. If false, this table will not be autovacuumed,
722 except to prevent transaction ID wraparound. See Section 24.1.5 for
723 more about wraparound prevention. Note that the autovacuum daemon
724 does not run at all (except to prevent transaction ID wraparound)
725 if the autovacuum parameter is false; setting individual tables'
726 storage parameters does not override that. Therefore there is
727 seldom much point in explicitly setting this storage parameter to
728 true, only to false.
729
730 autovacuum_vacuum_threshold, toast.autovacuum_vacuum_threshold
731 (integer)
732 Per-table value for autovacuum_vacuum_threshold parameter.
733
734 autovacuum_vacuum_scale_factor, toast.autovacuum_vacuum_scale_factor
735 (float4)
736 Per-table value for autovacuum_vacuum_scale_factor parameter.
737
738 autovacuum_analyze_threshold (integer)
739 Per-table value for autovacuum_analyze_threshold parameter.
740
741 autovacuum_analyze_scale_factor (float4)
742 Per-table value for autovacuum_analyze_scale_factor parameter.
743
744 autovacuum_vacuum_cost_delay, toast.autovacuum_vacuum_cost_delay
745 (integer)
746 Per-table value for autovacuum_vacuum_cost_delay parameter.
747
748 autovacuum_vacuum_cost_limit, toast.autovacuum_vacuum_cost_limit
749 (integer)
750 Per-table value for autovacuum_vacuum_cost_limit parameter.
751
752 autovacuum_freeze_min_age, toast.autovacuum_freeze_min_age (integer)
753 Per-table value for vacuum_freeze_min_age parameter. Note that
754 autovacuum will ignore per-table autovacuum_freeze_min_age
755 parameters that are larger than half the system-wide
756 autovacuum_freeze_max_age setting.
757
758 autovacuum_freeze_max_age, toast.autovacuum_freeze_max_age (integer)
759 Per-table value for autovacuum_freeze_max_age parameter. Note that
760 autovacuum will ignore per-table autovacuum_freeze_max_age
761 parameters that are larger than the system-wide setting (it can
762 only be set smaller).
763
764 autovacuum_freeze_table_age, toast.autovacuum_freeze_table_age
765 (integer)
766 Per-table value for vacuum_freeze_table_age parameter.
767
768 autovacuum_multixact_freeze_min_age,
769 toast.autovacuum_multixact_freeze_min_age (integer)
770 Per-table value for vacuum_multixact_freeze_min_age parameter. Note
771 that autovacuum will ignore per-table
772 autovacuum_multixact_freeze_min_age parameters that are larger than
773 half the system-wide autovacuum_multixact_freeze_max_age setting.
774
775 autovacuum_multixact_freeze_max_age,
776 toast.autovacuum_multixact_freeze_max_age (integer)
777 Per-table value for autovacuum_multixact_freeze_max_age parameter.
778 Note that autovacuum will ignore per-table
779 autovacuum_multixact_freeze_max_age parameters that are larger than
780 the system-wide setting (it can only be set smaller).
781
782 autovacuum_multixact_freeze_table_age,
783 toast.autovacuum_multixact_freeze_table_age (integer)
784 Per-table value for vacuum_multixact_freeze_table_age parameter.
785
786 log_autovacuum_min_duration, toast.log_autovacuum_min_duration
787 (integer)
788 Per-table value for log_autovacuum_min_duration parameter.
789
790 user_catalog_table (boolean)
791 Declare the table as an additional catalog table for purposes of
792 logical replication. See Section 48.6.2 for details. This parameter
793 cannot be set for TOAST tables.
794
796 Using OIDs in new applications is not recommended: where possible,
797 using an identity column or other sequence generator as the table's
798 primary key is preferred. However, if your application does make use of
799 OIDs to identify specific rows of a table, it is recommended to create
800 a unique constraint on the oid column of that table, to ensure that
801 OIDs in the table will indeed uniquely identify rows even after counter
802 wraparound. Avoid assuming that OIDs are unique across tables; if you
803 need a database-wide unique identifier, use the combination of tableoid
804 and row OID for the purpose.
805
806 Tip
807 The use of OIDS=FALSE is not recommended for tables with no primary
808 key, since without either an OID or a unique data key, it is
809 difficult to identify specific rows.
810
811 PostgreSQL automatically creates an index for each unique constraint
812 and primary key constraint to enforce uniqueness. Thus, it is not
813 necessary to create an index explicitly for primary key columns. (See
814 CREATE INDEX (CREATE_INDEX(7)) for more information.)
815
816 Unique constraints and primary keys are not inherited in the current
817 implementation. This makes the combination of inheritance and unique
818 constraints rather dysfunctional.
819
820 A table cannot have more than 1600 columns. (In practice, the effective
821 limit is usually lower because of tuple-length constraints.)
822
824 Create table films and table distributors:
825
826 CREATE TABLE films (
827 code char(5) CONSTRAINT firstkey PRIMARY KEY,
828 title varchar(40) NOT NULL,
829 did integer NOT NULL,
830 date_prod date,
831 kind varchar(10),
832 len interval hour to minute
833 );
834
835 CREATE TABLE distributors (
836 did integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
837 name varchar(40) NOT NULL CHECK (name <> '')
838 );
839
840 Create a table with a 2-dimensional array:
841
842 CREATE TABLE array_int (
843 vector int[][]
844 );
845
846 Define a unique table constraint for the table films. Unique table
847 constraints can be defined on one or more columns of the table:
848
849 CREATE TABLE films (
850 code char(5),
851 title varchar(40),
852 did integer,
853 date_prod date,
854 kind varchar(10),
855 len interval hour to minute,
856 CONSTRAINT production UNIQUE(date_prod)
857 );
858
859 Define a check column constraint:
860
861 CREATE TABLE distributors (
862 did integer CHECK (did > 100),
863 name varchar(40)
864 );
865
866 Define a check table constraint:
867
868 CREATE TABLE distributors (
869 did integer,
870 name varchar(40),
871 CONSTRAINT con1 CHECK (did > 100 AND name <> '')
872 );
873
874 Define a primary key table constraint for the table films:
875
876 CREATE TABLE films (
877 code char(5),
878 title varchar(40),
879 did integer,
880 date_prod date,
881 kind varchar(10),
882 len interval hour to minute,
883 CONSTRAINT code_title PRIMARY KEY(code,title)
884 );
885
886 Define a primary key constraint for table distributors. The following
887 two examples are equivalent, the first using the table constraint
888 syntax, the second the column constraint syntax:
889
890 CREATE TABLE distributors (
891 did integer,
892 name varchar(40),
893 PRIMARY KEY(did)
894 );
895
896 CREATE TABLE distributors (
897 did integer PRIMARY KEY,
898 name varchar(40)
899 );
900
901 Assign a literal constant default value for the column name, arrange
902 for the default value of column did to be generated by selecting the
903 next value of a sequence object, and make the default value of modtime
904 be the time at which the row is inserted:
905
906 CREATE TABLE distributors (
907 name varchar(40) DEFAULT 'Luso Films',
908 did integer DEFAULT nextval('distributors_serial'),
909 modtime timestamp DEFAULT current_timestamp
910 );
911
912 Define two NOT NULL column constraints on the table distributors, one
913 of which is explicitly given a name:
914
915 CREATE TABLE distributors (
916 did integer CONSTRAINT no_null NOT NULL,
917 name varchar(40) NOT NULL
918 );
919
920 Define a unique constraint for the name column:
921
922 CREATE TABLE distributors (
923 did integer,
924 name varchar(40) UNIQUE
925 );
926
927 The same, specified as a table constraint:
928
929 CREATE TABLE distributors (
930 did integer,
931 name varchar(40),
932 UNIQUE(name)
933 );
934
935 Create the same table, specifying 70% fill factor for both the table
936 and its unique index:
937
938 CREATE TABLE distributors (
939 did integer,
940 name varchar(40),
941 UNIQUE(name) WITH (fillfactor=70)
942 )
943 WITH (fillfactor=70);
944
945 Create table circles with an exclusion constraint that prevents any two
946 circles from overlapping:
947
948 CREATE TABLE circles (
949 c circle,
950 EXCLUDE USING gist (c WITH &&)
951 );
952
953 Create table cinemas in tablespace diskvol1:
954
955 CREATE TABLE cinemas (
956 id serial,
957 name text,
958 location text
959 ) TABLESPACE diskvol1;
960
961 Create a composite type and a typed table:
962
963 CREATE TYPE employee_type AS (name text, salary numeric);
964
965 CREATE TABLE employees OF employee_type (
966 PRIMARY KEY (name),
967 salary WITH OPTIONS DEFAULT 1000
968 );
969
970 Create a range partitioned table:
971
972 CREATE TABLE measurement (
973 logdate date not null,
974 peaktemp int,
975 unitsales int
976 ) PARTITION BY RANGE (logdate);
977
978 Create a range partitioned table with multiple columns in the partition
979 key:
980
981 CREATE TABLE measurement_year_month (
982 logdate date not null,
983 peaktemp int,
984 unitsales int
985 ) PARTITION BY RANGE (EXTRACT(YEAR FROM logdate), EXTRACT(MONTH FROM logdate));
986
987 Create a list partitioned table:
988
989 CREATE TABLE cities (
990 city_id bigserial not null,
991 name text not null,
992 population bigint
993 ) PARTITION BY LIST (left(lower(name), 1));
994
995 Create partition of a range partitioned table:
996
997 CREATE TABLE measurement_y2016m07
998 PARTITION OF measurement (
999 unitsales DEFAULT 0
1000 ) FOR VALUES FROM ('2016-07-01') TO ('2016-08-01');
1001
1002 Create a few partitions of a range partitioned table with multiple
1003 columns in the partition key:
1004
1005 CREATE TABLE measurement_ym_older
1006 PARTITION OF measurement_year_month
1007 FOR VALUES FROM (MINVALUE, MINVALUE) TO (2016, 11);
1008
1009 CREATE TABLE measurement_ym_y2016m11
1010 PARTITION OF measurement_year_month
1011 FOR VALUES FROM (2016, 11) TO (2016, 12);
1012
1013 CREATE TABLE measurement_ym_y2016m12
1014 PARTITION OF measurement_year_month
1015 FOR VALUES FROM (2016, 12) TO (2017, 01);
1016
1017 CREATE TABLE measurement_ym_y2017m01
1018 PARTITION OF measurement_year_month
1019 FOR VALUES FROM (2017, 01) TO (2017, 02);
1020
1021 Create partition of a list partitioned table:
1022
1023 CREATE TABLE cities_ab
1024 PARTITION OF cities (
1025 CONSTRAINT city_id_nonzero CHECK (city_id != 0)
1026 ) FOR VALUES IN ('a', 'b');
1027
1028 Create partition of a list partitioned table that is itself further
1029 partitioned and then add a partition to it:
1030
1031 CREATE TABLE cities_ab
1032 PARTITION OF cities (
1033 CONSTRAINT city_id_nonzero CHECK (city_id != 0)
1034 ) FOR VALUES IN ('a', 'b') PARTITION BY RANGE (population);
1035
1036 CREATE TABLE cities_ab_10000_to_100000
1037 PARTITION OF cities_ab FOR VALUES FROM (10000) TO (100000);
1038
1040 The CREATE TABLE command conforms to the SQL standard, with exceptions
1041 listed below.
1042
1043 Temporary Tables
1044 Although the syntax of CREATE TEMPORARY TABLE resembles that of the SQL
1045 standard, the effect is not the same. In the standard, temporary tables
1046 are defined just once and automatically exist (starting with empty
1047 contents) in every session that needs them. PostgreSQL instead
1048 requires each session to issue its own CREATE TEMPORARY TABLE command
1049 for each temporary table to be used. This allows different sessions to
1050 use the same temporary table name for different purposes, whereas the
1051 standard's approach constrains all instances of a given temporary table
1052 name to have the same table structure.
1053
1054 The standard's definition of the behavior of temporary tables is widely
1055 ignored. PostgreSQL's behavior on this point is similar to that of
1056 several other SQL databases.
1057
1058 The SQL standard also distinguishes between global and local temporary
1059 tables, where a local temporary table has a separate set of contents
1060 for each SQL module within each session, though its definition is still
1061 shared across sessions. Since PostgreSQL does not support SQL modules,
1062 this distinction is not relevant in PostgreSQL.
1063
1064 For compatibility's sake, PostgreSQL will accept the GLOBAL and LOCAL
1065 keywords in a temporary table declaration, but they currently have no
1066 effect. Use of these keywords is discouraged, since future versions of
1067 PostgreSQL might adopt a more standard-compliant interpretation of
1068 their meaning.
1069
1070 The ON COMMIT clause for temporary tables also resembles the SQL
1071 standard, but has some differences. If the ON COMMIT clause is omitted,
1072 SQL specifies that the default behavior is ON COMMIT DELETE ROWS.
1073 However, the default behavior in PostgreSQL is ON COMMIT PRESERVE ROWS.
1074 The ON COMMIT DROP option does not exist in SQL.
1075
1076 Non-deferred Uniqueness Constraints
1077 When a UNIQUE or PRIMARY KEY constraint is not deferrable, PostgreSQL
1078 checks for uniqueness immediately whenever a row is inserted or
1079 modified. The SQL standard says that uniqueness should be enforced only
1080 at the end of the statement; this makes a difference when, for example,
1081 a single command updates multiple key values. To obtain
1082 standard-compliant behavior, declare the constraint as DEFERRABLE but
1083 not deferred (i.e., INITIALLY IMMEDIATE). Be aware that this can be
1084 significantly slower than immediate uniqueness checking.
1085
1086 Column Check Constraints
1087 The SQL standard says that CHECK column constraints can only refer to
1088 the column they apply to; only CHECK table constraints can refer to
1089 multiple columns. PostgreSQL does not enforce this restriction; it
1090 treats column and table check constraints alike.
1091
1092 EXCLUDE Constraint
1093 The EXCLUDE constraint type is a PostgreSQL extension.
1094
1095 NULL “Constraint”
1096 The NULL “constraint” (actually a non-constraint) is a PostgreSQL
1097 extension to the SQL standard that is included for compatibility with
1098 some other database systems (and for symmetry with the NOT NULL
1099 constraint). Since it is the default for any column, its presence is
1100 simply noise.
1101
1102 Inheritance
1103 Multiple inheritance via the INHERITS clause is a PostgreSQL language
1104 extension. SQL:1999 and later define single inheritance using a
1105 different syntax and different semantics. SQL:1999-style inheritance is
1106 not yet supported by PostgreSQL.
1107
1108 Zero-column Tables
1109 PostgreSQL allows a table of no columns to be created (for example,
1110 CREATE TABLE foo();). This is an extension from the SQL standard, which
1111 does not allow zero-column tables. Zero-column tables are not in
1112 themselves very useful, but disallowing them creates odd special cases
1113 for ALTER TABLE DROP COLUMN, so it seems cleaner to ignore this spec
1114 restriction.
1115
1116 Multiple Identity Columns
1117 PostgreSQL allows a table to have more than one identity column. The
1118 standard specifies that a table can have at most one identity column.
1119 This is relaxed mainly to give more flexibility for doing schema
1120 changes or migrations. Note that the INSERT command supports only one
1121 override clause that applies to the entire statement, so having
1122 multiple identity columns with different behaviors is not well
1123 supported.
1124
1125 LIKE Clause
1126 While a LIKE clause exists in the SQL standard, many of the options
1127 that PostgreSQL accepts for it are not in the standard, and some of the
1128 standard's options are not implemented by PostgreSQL.
1129
1130 WITH Clause
1131 The WITH clause is a PostgreSQL extension; neither storage parameters
1132 nor OIDs are in the standard.
1133
1134 Tablespaces
1135 The PostgreSQL concept of tablespaces is not part of the standard.
1136 Hence, the clauses TABLESPACE and USING INDEX TABLESPACE are
1137 extensions.
1138
1139 Typed Tables
1140 Typed tables implement a subset of the SQL standard. According to the
1141 standard, a typed table has columns corresponding to the underlying
1142 composite type as well as one other column that is the
1143 “self-referencing column”. PostgreSQL does not support these
1144 self-referencing columns explicitly, but the same effect can be had
1145 using the OID feature.
1146
1147 PARTITION BY Clause
1148 The PARTITION BY clause is a PostgreSQL extension.
1149
1150 PARTITION OF Clause
1151 The PARTITION OF clause is a PostgreSQL extension.
1152
1154 ALTER TABLE (ALTER_TABLE(7)), DROP TABLE (DROP_TABLE(7)), CREATE TABLE
1155 AS (CREATE_TABLE_AS(7)), CREATE TABLESPACE (CREATE_TABLESPACE(7)),
1156 CREATE TYPE (CREATE_TYPE(7))
1157
1158
1159
1160PostgreSQL 10.7 2019 CREATE TABLE(7)