~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/sql-createtable.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>CREATE TABLE</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REV="MADE"
 
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
 
11
REL="HOME"
 
12
TITLE="PostgreSQL 9.1beta1 Documentation"
 
13
HREF="index.html"><LINK
 
14
REL="UP"
 
15
TITLE="SQL Commands"
 
16
HREF="sql-commands.html"><LINK
 
17
REL="PREVIOUS"
 
18
TITLE="CREATE SERVER"
 
19
HREF="sql-createserver.html"><LINK
 
20
REL="NEXT"
 
21
TITLE="CREATE TABLE AS"
 
22
HREF="sql-createtableas.html"><LINK
 
23
REL="STYLESHEET"
 
24
TYPE="text/css"
 
25
HREF="stylesheet.css"><META
 
26
HTTP-EQUIV="Content-Type"
 
27
CONTENT="text/html; charset=ISO-8859-1"><META
 
28
NAME="creation"
 
29
CONTENT="2011-04-27T21:20:33"></HEAD
 
30
><BODY
 
31
CLASS="REFENTRY"
 
32
><DIV
 
33
CLASS="NAVHEADER"
 
34
><TABLE
 
35
SUMMARY="Header navigation table"
 
36
WIDTH="100%"
 
37
BORDER="0"
 
38
CELLPADDING="0"
 
39
CELLSPACING="0"
 
40
><TR
 
41
><TH
 
42
COLSPAN="5"
 
43
ALIGN="center"
 
44
VALIGN="bottom"
 
45
><A
 
46
HREF="index.html"
 
47
>PostgreSQL 9.1beta1 Documentation</A
 
48
></TH
 
49
></TR
 
50
><TR
 
51
><TD
 
52
WIDTH="10%"
 
53
ALIGN="left"
 
54
VALIGN="top"
 
55
><A
 
56
TITLE="CREATE SERVER"
 
57
HREF="sql-createserver.html"
 
58
ACCESSKEY="P"
 
59
>Prev</A
 
60
></TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="left"
 
64
VALIGN="top"
 
65
><A
 
66
TITLE="CREATE SERVER"
 
67
HREF="sql-createserver.html"
 
68
>Fast Backward</A
 
69
></TD
 
70
><TD
 
71
WIDTH="60%"
 
72
ALIGN="center"
 
73
VALIGN="bottom"
 
74
></TD
 
75
><TD
 
76
WIDTH="10%"
 
77
ALIGN="right"
 
78
VALIGN="top"
 
79
><A
 
80
TITLE="CREATE TABLE AS"
 
81
HREF="sql-createtableas.html"
 
82
>Fast Forward</A
 
83
></TD
 
84
><TD
 
85
WIDTH="10%"
 
86
ALIGN="right"
 
87
VALIGN="top"
 
88
><A
 
89
TITLE="CREATE TABLE AS"
 
90
HREF="sql-createtableas.html"
 
91
ACCESSKEY="N"
 
92
>Next</A
 
93
></TD
 
94
></TR
 
95
></TABLE
 
96
><HR
 
97
ALIGN="LEFT"
 
98
WIDTH="100%"></DIV
 
99
><H1
 
100
><A
 
101
NAME="SQL-CREATETABLE"
 
102
></A
 
103
>CREATE TABLE</H1
 
104
><DIV
 
105
CLASS="REFNAMEDIV"
 
106
><A
 
107
NAME="AEN67189"
 
108
></A
 
109
><H2
 
110
>Name</H2
 
111
>CREATE TABLE&nbsp;--&nbsp;define a new table</DIV
 
112
><DIV
 
113
CLASS="REFSYNOPSISDIV"
 
114
><A
 
115
NAME="AEN67194"
 
116
></A
 
117
><H2
 
118
>Synopsis</H2
 
119
><PRE
 
120
CLASS="SYNOPSIS"
 
121
>CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <TT
 
122
CLASS="REPLACEABLE"
 
123
><I
 
124
>table_name</I
 
125
></TT
 
126
> ( [
 
127
  { <TT
 
128
CLASS="REPLACEABLE"
 
129
><I
 
130
>column_name</I
 
131
></TT
 
132
> <TT
 
133
CLASS="REPLACEABLE"
 
134
><I
 
135
>data_type</I
 
136
></TT
 
137
> [ COLLATE <TT
 
138
CLASS="REPLACEABLE"
 
139
><I
 
140
>collation</I
 
141
></TT
 
142
> ] [ <TT
 
143
CLASS="REPLACEABLE"
 
144
><I
 
145
>column_constraint</I
 
146
></TT
 
147
> [ ... ] ]
 
148
    | <TT
 
149
CLASS="REPLACEABLE"
 
150
><I
 
151
>table_constraint</I
 
152
></TT
 
153
>
 
154
    | LIKE <TT
 
155
CLASS="REPLACEABLE"
 
156
><I
 
157
>parent_table</I
 
158
></TT
 
159
> [ <TT
 
160
CLASS="REPLACEABLE"
 
161
><I
 
162
>like_option</I
 
163
></TT
 
164
> ... ] }
 
165
    [, ... ]
 
166
] )
 
167
[ INHERITS ( <TT
 
168
CLASS="REPLACEABLE"
 
169
><I
 
170
>parent_table</I
 
171
></TT
 
172
> [, ... ] ) ]
 
173
[ WITH ( <TT
 
174
CLASS="REPLACEABLE"
 
175
><I
 
176
>storage_parameter</I
 
177
></TT
 
178
> [= <TT
 
179
CLASS="REPLACEABLE"
 
180
><I
 
181
>value</I
 
182
></TT
 
183
>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
 
184
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
 
185
[ TABLESPACE <TT
 
186
CLASS="REPLACEABLE"
 
187
><I
 
188
>tablespace</I
 
189
></TT
 
190
> ]
 
191
 
 
192
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXISTS ] <TT
 
193
CLASS="REPLACEABLE"
 
194
><I
 
195
>table_name</I
 
196
></TT
 
197
>
 
198
    OF <TT
 
199
CLASS="REPLACEABLE"
 
200
><I
 
201
>type_name</I
 
202
></TT
 
203
> [ (
 
204
  { <TT
 
205
CLASS="REPLACEABLE"
 
206
><I
 
207
>column_name</I
 
208
></TT
 
209
> WITH OPTIONS [ <TT
 
210
CLASS="REPLACEABLE"
 
211
><I
 
212
>column_constraint</I
 
213
></TT
 
214
> [ ... ] ]
 
215
    | <TT
 
216
CLASS="REPLACEABLE"
 
217
><I
 
218
>table_constraint</I
 
219
></TT
 
220
> }
 
221
    [, ... ]
 
222
) ]
 
223
[ WITH ( <TT
 
224
CLASS="REPLACEABLE"
 
225
><I
 
226
>storage_parameter</I
 
227
></TT
 
228
> [= <TT
 
229
CLASS="REPLACEABLE"
 
230
><I
 
231
>value</I
 
232
></TT
 
233
>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
 
234
[ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
 
235
[ TABLESPACE <TT
 
236
CLASS="REPLACEABLE"
 
237
><I
 
238
>tablespace</I
 
239
></TT
 
240
> ]
 
241
 
 
242
<SPAN
 
243
CLASS="phrase"
 
244
><SPAN
 
245
CLASS="PHRASE"
 
246
>where <TT
 
247
CLASS="REPLACEABLE"
 
248
><I
 
249
>column_constraint</I
 
250
></TT
 
251
> is:</SPAN
 
252
></SPAN
 
253
>
 
254
 
 
255
[ CONSTRAINT <TT
 
256
CLASS="REPLACEABLE"
 
257
><I
 
258
>constraint_name</I
 
259
></TT
 
260
> ]
 
261
{ NOT NULL |
 
262
  NULL |
 
263
  CHECK ( <TT
 
264
CLASS="REPLACEABLE"
 
265
><I
 
266
>expression</I
 
267
></TT
 
268
> ) |
 
269
  DEFAULT <TT
 
270
CLASS="REPLACEABLE"
 
271
><I
 
272
>default_expr</I
 
273
></TT
 
274
> |
 
275
  UNIQUE <TT
 
276
CLASS="REPLACEABLE"
 
277
><I
 
278
>index_parameters</I
 
279
></TT
 
280
> |
 
281
  PRIMARY KEY <TT
 
282
CLASS="REPLACEABLE"
 
283
><I
 
284
>index_parameters</I
 
285
></TT
 
286
> |
 
287
  REFERENCES <TT
 
288
CLASS="REPLACEABLE"
 
289
><I
 
290
>reftable</I
 
291
></TT
 
292
> [ ( <TT
 
293
CLASS="REPLACEABLE"
 
294
><I
 
295
>refcolumn</I
 
296
></TT
 
297
> ) ] [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ]
 
298
    [ ON DELETE <TT
 
299
CLASS="REPLACEABLE"
 
300
><I
 
301
>action</I
 
302
></TT
 
303
> ] [ ON UPDATE <TT
 
304
CLASS="REPLACEABLE"
 
305
><I
 
306
>action</I
 
307
></TT
 
308
> ] }
 
309
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
 
310
 
 
311
<SPAN
 
312
CLASS="phrase"
 
313
><SPAN
 
314
CLASS="PHRASE"
 
315
>and <TT
 
316
CLASS="REPLACEABLE"
 
317
><I
 
318
>table_constraint</I
 
319
></TT
 
320
> is:</SPAN
 
321
></SPAN
 
322
>
 
323
 
 
324
[ CONSTRAINT <TT
 
325
CLASS="REPLACEABLE"
 
326
><I
 
327
>constraint_name</I
 
328
></TT
 
329
> ]
 
330
{ CHECK ( <TT
 
331
CLASS="REPLACEABLE"
 
332
><I
 
333
>expression</I
 
334
></TT
 
335
> ) |
 
336
  UNIQUE ( <TT
 
337
CLASS="REPLACEABLE"
 
338
><I
 
339
>column_name</I
 
340
></TT
 
341
> [, ... ] ) <TT
 
342
CLASS="REPLACEABLE"
 
343
><I
 
344
>index_parameters</I
 
345
></TT
 
346
> |
 
347
  PRIMARY KEY ( <TT
 
348
CLASS="REPLACEABLE"
 
349
><I
 
350
>column_name</I
 
351
></TT
 
352
> [, ... ] ) <TT
 
353
CLASS="REPLACEABLE"
 
354
><I
 
355
>index_parameters</I
 
356
></TT
 
357
> |
 
358
  EXCLUDE [ USING <TT
 
359
CLASS="REPLACEABLE"
 
360
><I
 
361
>index_method</I
 
362
></TT
 
363
> ] ( <TT
 
364
CLASS="REPLACEABLE"
 
365
><I
 
366
>exclude_element</I
 
367
></TT
 
368
> WITH <TT
 
369
CLASS="REPLACEABLE"
 
370
><I
 
371
>operator</I
 
372
></TT
 
373
> [, ... ] ) <TT
 
374
CLASS="REPLACEABLE"
 
375
><I
 
376
>index_parameters</I
 
377
></TT
 
378
> [ WHERE ( <TT
 
379
CLASS="REPLACEABLE"
 
380
><I
 
381
>predicate</I
 
382
></TT
 
383
> ) ] |
 
384
  FOREIGN KEY ( <TT
 
385
CLASS="REPLACEABLE"
 
386
><I
 
387
>column_name</I
 
388
></TT
 
389
> [, ... ] ) REFERENCES <TT
 
390
CLASS="REPLACEABLE"
 
391
><I
 
392
>reftable</I
 
393
></TT
 
394
> [ ( <TT
 
395
CLASS="REPLACEABLE"
 
396
><I
 
397
>refcolumn</I
 
398
></TT
 
399
> [, ... ] ) ]
 
400
    [ MATCH FULL | MATCH PARTIAL | MATCH SIMPLE ] [ ON DELETE <TT
 
401
CLASS="REPLACEABLE"
 
402
><I
 
403
>action</I
 
404
></TT
 
405
> ] [ ON UPDATE <TT
 
406
CLASS="REPLACEABLE"
 
407
><I
 
408
>action</I
 
409
></TT
 
410
> ] }
 
411
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
 
412
 
 
413
<SPAN
 
414
CLASS="phrase"
 
415
><SPAN
 
416
CLASS="PHRASE"
 
417
>and <TT
 
418
CLASS="REPLACEABLE"
 
419
><I
 
420
>like_option</I
 
421
></TT
 
422
> is:</SPAN
 
423
></SPAN
 
424
>
 
425
 
 
426
{ INCLUDING | EXCLUDING } { DEFAULTS | CONSTRAINTS | INDEXES | STORAGE | COMMENTS | ALL }
 
427
 
 
428
<SPAN
 
429
CLASS="phrase"
 
430
><SPAN
 
431
CLASS="PHRASE"
 
432
><TT
 
433
CLASS="REPLACEABLE"
 
434
><I
 
435
>index_parameters</I
 
436
></TT
 
437
> in <TT
 
438
CLASS="LITERAL"
 
439
>UNIQUE</TT
 
440
>, <TT
 
441
CLASS="LITERAL"
 
442
>PRIMARY KEY</TT
 
443
>, and <TT
 
444
CLASS="LITERAL"
 
445
>EXCLUDE</TT
 
446
> constraints are:</SPAN
 
447
></SPAN
 
448
>
 
449
 
 
450
[ WITH ( <TT
 
451
CLASS="REPLACEABLE"
 
452
><I
 
453
>storage_parameter</I
 
454
></TT
 
455
> [= <TT
 
456
CLASS="REPLACEABLE"
 
457
><I
 
458
>value</I
 
459
></TT
 
460
>] [, ... ] ) ]
 
461
[ USING INDEX TABLESPACE <TT
 
462
CLASS="REPLACEABLE"
 
463
><I
 
464
>tablespace</I
 
465
></TT
 
466
> ]
 
467
 
 
468
<SPAN
 
469
CLASS="phrase"
 
470
><SPAN
 
471
CLASS="PHRASE"
 
472
><TT
 
473
CLASS="REPLACEABLE"
 
474
><I
 
475
>exclude_element</I
 
476
></TT
 
477
> in an <TT
 
478
CLASS="LITERAL"
 
479
>EXCLUDE</TT
 
480
> constraint is:</SPAN
 
481
></SPAN
 
482
>
 
483
 
 
484
{ <TT
 
485
CLASS="REPLACEABLE"
 
486
><I
 
487
>column</I
 
488
></TT
 
489
> | ( <TT
 
490
CLASS="REPLACEABLE"
 
491
><I
 
492
>expression</I
 
493
></TT
 
494
> ) } [ <TT
 
495
CLASS="REPLACEABLE"
 
496
><I
 
497
>opclass</I
 
498
></TT
 
499
> ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ]</PRE
 
500
></DIV
 
501
><DIV
 
502
CLASS="REFSECT1"
 
503
><A
 
504
NAME="SQL-CREATETABLE-DESCRIPTION"
 
505
></A
 
506
><H2
 
507
>Description</H2
 
508
><P
 
509
>   <TT
 
510
CLASS="COMMAND"
 
511
>CREATE TABLE</TT
 
512
> will create a new, initially empty table
 
513
   in the current database. The table will be owned by the user issuing the
 
514
   command.
 
515
  </P
 
516
><P
 
517
>   If a schema name is given (for example, <TT
 
518
CLASS="LITERAL"
 
519
>CREATE TABLE
 
520
   myschema.mytable ...</TT
 
521
>) then the table is created in the specified
 
522
   schema.  Otherwise it is created in the current schema.  Temporary
 
523
   tables exist in a special schema, so a schema name cannot be given
 
524
   when creating a temporary table.  The name of the table must be
 
525
   distinct from the name of any other table, sequence, index, view,
 
526
   or foreign table in the same schema.
 
527
  </P
 
528
><P
 
529
>   <TT
 
530
CLASS="COMMAND"
 
531
>CREATE TABLE</TT
 
532
> also automatically creates a data
 
533
   type that represents the composite type corresponding
 
534
   to one row of the table.  Therefore, tables cannot have the same
 
535
   name as any existing data type in the same schema.
 
536
  </P
 
537
><P
 
538
>   The optional constraint clauses specify constraints (tests) that
 
539
   new or updated rows must satisfy for an insert or update operation
 
540
   to succeed.  A constraint is an SQL object that helps define the
 
541
   set of valid values in the table in various ways.
 
542
  </P
 
543
><P
 
544
>   There are two ways to define constraints: table constraints and
 
545
   column constraints.  A column constraint is defined as part of a
 
546
   column definition.  A table constraint definition is not tied to a
 
547
   particular column, and it can encompass more than one column.
 
548
   Every column constraint can also be written as a table constraint;
 
549
   a column constraint is only a notational convenience for use when the
 
550
   constraint only affects one column.
 
551
  </P
 
552
></DIV
 
553
><DIV
 
554
CLASS="REFSECT1"
 
555
><A
 
556
NAME="AEN67271"
 
557
></A
 
558
><H2
 
559
>Parameters</H2
 
560
><P
 
561
></P
 
562
><DIV
 
563
CLASS="VARIABLELIST"
 
564
><DL
 
565
><DT
 
566
><TT
 
567
CLASS="LITERAL"
 
568
>TEMPORARY</TT
 
569
> or <TT
 
570
CLASS="LITERAL"
 
571
>TEMP</TT
 
572
></DT
 
573
><DD
 
574
><P
 
575
>      If specified, the table is created as a temporary table.
 
576
      Temporary tables are automatically dropped at the end of a
 
577
      session, or optionally at the end of the current transaction
 
578
      (see <TT
 
579
CLASS="LITERAL"
 
580
>ON COMMIT</TT
 
581
> below).  Existing permanent
 
582
      tables with the same name are not visible to the current session
 
583
      while the temporary table exists, unless they are referenced
 
584
      with schema-qualified names. Any indexes created on a temporary
 
585
      table are automatically temporary as well.
 
586
     </P
 
587
><P
 
588
>      The <A
 
589
HREF="routine-vacuuming.html#AUTOVACUUM"
 
590
>autovacuum daemon</A
 
591
> cannot
 
592
      access and therefore cannot vacuum or analyze temporary tables.
 
593
      For this reason, appropriate vacuum and analyze operations should be
 
594
      performed via session SQL commands.  For example, if a temporary
 
595
      table is going to be used in complex queries, it is wise to run
 
596
      <TT
 
597
CLASS="COMMAND"
 
598
>ANALYZE</TT
 
599
> on the temporary table after it is populated.
 
600
     </P
 
601
><P
 
602
>      Optionally, <TT
 
603
CLASS="LITERAL"
 
604
>GLOBAL</TT
 
605
> or <TT
 
606
CLASS="LITERAL"
 
607
>LOCAL</TT
 
608
>
 
609
      can be written before <TT
 
610
CLASS="LITERAL"
 
611
>TEMPORARY</TT
 
612
> or <TT
 
613
CLASS="LITERAL"
 
614
>TEMP</TT
 
615
>.
 
616
      This makes no difference in <SPAN
 
617
CLASS="PRODUCTNAME"
 
618
>PostgreSQL</SPAN
 
619
>, but see
 
620
      <A
 
621
HREF="sql-createtable.html#SQL-CREATETABLE-COMPATIBILITY"
 
622
><I
 
623
>Compatibility</I
 
624
></A
 
625
>.
 
626
     </P
 
627
></DD
 
628
><DT
 
629
><TT
 
630
CLASS="LITERAL"
 
631
>UNLOGGED</TT
 
632
></DT
 
633
><DD
 
634
><P
 
635
>      If specified, the table is created as an unlogged table.  Data written
 
636
      to unlogged tables is not written to the write-ahead log (see <A
 
637
HREF="wal.html"
 
638
>Chapter 29</A
 
639
>), which makes them considerably faster than ordinary
 
640
      tables.  However, they are not crash-safe: an unlogged table is
 
641
      automatically truncated after a crash or unclean shutdown.  The contents
 
642
      of an unlogged table are also not replicated to standby servers.
 
643
      Any indexes created on an unlogged table are automatically unlogged as
 
644
      well; however, unlogged <A
 
645
HREF="gist.html"
 
646
>GiST indexes</A
 
647
> are
 
648
      currently not supported and cannot be created on an unlogged table.
 
649
     </P
 
650
></DD
 
651
><DT
 
652
><TT
 
653
CLASS="LITERAL"
 
654
>IF NOT EXISTS</TT
 
655
></DT
 
656
><DD
 
657
><P
 
658
>      Do not throw an error if a relation with the same name already exists.
 
659
      A notice is issued in this case.  Note that there is no guarantee that
 
660
      the existing relation is anything like the one that would have been
 
661
      created.
 
662
     </P
 
663
></DD
 
664
><DT
 
665
><TT
 
666
CLASS="REPLACEABLE"
 
667
><I
 
668
>table_name</I
 
669
></TT
 
670
></DT
 
671
><DD
 
672
><P
 
673
>      The name (optionally schema-qualified) of the table to be created.
 
674
     </P
 
675
></DD
 
676
><DT
 
677
><TT
 
678
CLASS="LITERAL"
 
679
>OF <TT
 
680
CLASS="REPLACEABLE"
 
681
><I
 
682
>type_name</I
 
683
></TT
 
684
></TT
 
685
></DT
 
686
><DD
 
687
><P
 
688
>      Creates a <I
 
689
CLASS="FIRSTTERM"
 
690
>typed table</I
 
691
>, which takes its
 
692
      structure from the specified composite type (name optionally
 
693
      schema-qualified).  A typed table is tied to its type; for
 
694
      example the table will be dropped if the type is dropped
 
695
      (with <TT
 
696
CLASS="LITERAL"
 
697
>DROP TYPE ... CASCADE</TT
 
698
>).
 
699
     </P
 
700
><P
 
701
>      When a typed table is created, then the data types of the
 
702
      columns are determined by the underlying composite type and are
 
703
      not specified by the <TT
 
704
CLASS="LITERAL"
 
705
>CREATE TABLE</TT
 
706
> command.
 
707
      But the <TT
 
708
CLASS="LITERAL"
 
709
>CREATE TABLE</TT
 
710
> command can add defaults
 
711
      and constraints to the table and can specify storage parameters.
 
712
     </P
 
713
></DD
 
714
><DT
 
715
><TT
 
716
CLASS="REPLACEABLE"
 
717
><I
 
718
>column_name</I
 
719
></TT
 
720
></DT
 
721
><DD
 
722
><P
 
723
>      The name of a column to be created in the new table.
 
724
     </P
 
725
></DD
 
726
><DT
 
727
><TT
 
728
CLASS="REPLACEABLE"
 
729
><I
 
730
>data_type</I
 
731
></TT
 
732
></DT
 
733
><DD
 
734
><P
 
735
>      The data type of the column. This can include array
 
736
      specifiers. For more information on the data types supported by
 
737
      <SPAN
 
738
CLASS="PRODUCTNAME"
 
739
>PostgreSQL</SPAN
 
740
>, refer to <A
 
741
HREF="datatype.html"
 
742
>Chapter 8</A
 
743
>.
 
744
     </P
 
745
></DD
 
746
><DT
 
747
><TT
 
748
CLASS="LITERAL"
 
749
>COLLATE <TT
 
750
CLASS="REPLACEABLE"
 
751
><I
 
752
>collation</I
 
753
></TT
 
754
></TT
 
755
></DT
 
756
><DD
 
757
><P
 
758
>      The <TT
 
759
CLASS="LITERAL"
 
760
>COLLATE</TT
 
761
> clause assigns a collation to
 
762
      the column (which must be of a collatable data type).
 
763
      If not specified, the column data type's default collation is used.
 
764
     </P
 
765
></DD
 
766
><DT
 
767
><TT
 
768
CLASS="LITERAL"
 
769
>INHERITS ( <TT
 
770
CLASS="REPLACEABLE"
 
771
><I
 
772
>parent_table</I
 
773
></TT
 
774
> [, ... ] )</TT
 
775
></DT
 
776
><DD
 
777
><P
 
778
>      The optional <TT
 
779
CLASS="LITERAL"
 
780
>INHERITS</TT
 
781
> clause specifies a list of
 
782
      tables from which the new table automatically inherits all
 
783
      columns.
 
784
     </P
 
785
><P
 
786
>      Use of <TT
 
787
CLASS="LITERAL"
 
788
>INHERITS</TT
 
789
> creates a persistent relationship
 
790
      between the new child table and its parent table(s).  Schema
 
791
      modifications to the parent(s) normally propagate to children
 
792
      as well, and by default the data of the child table is included in
 
793
      scans of the parent(s).
 
794
     </P
 
795
><P
 
796
>      If the same column name exists in more than one parent
 
797
      table, an error is reported unless the data types of the columns
 
798
      match in each of the parent tables.  If there is no conflict,
 
799
      then the duplicate columns are merged to form a single column in
 
800
      the new table.  If the column name list of the new table
 
801
      contains a column name that is also inherited, the data type must
 
802
      likewise match the inherited column(s), and the column
 
803
      definitions are merged into one.  If the
 
804
      new table explicitly specifies a default value for the column,
 
805
      this default overrides any defaults from inherited declarations
 
806
      of the column.  Otherwise, any parents that specify default
 
807
      values for the column must all specify the same default, or an
 
808
      error will be reported.
 
809
     </P
 
810
><P
 
811
>      <TT
 
812
CLASS="LITERAL"
 
813
>CHECK</TT
 
814
> constraints are merged in essentially the same way as
 
815
      columns: if multiple parent tables and/or the new table definition
 
816
      contain identically-named <TT
 
817
CLASS="LITERAL"
 
818
>CHECK</TT
 
819
> constraints, these
 
820
      constraints must all have the same check expression, or an error will be
 
821
      reported.  Constraints having the same name and expression will
 
822
      be merged into one copy.  Notice that an unnamed <TT
 
823
CLASS="LITERAL"
 
824
>CHECK</TT
 
825
>
 
826
      constraint in the new table will never be merged, since a unique name
 
827
      will always be chosen for it.
 
828
     </P
 
829
><P
 
830
>      Column <TT
 
831
CLASS="LITERAL"
 
832
>STORAGE</TT
 
833
> settings are also copied from parent tables.
 
834
     </P
 
835
></DD
 
836
><DT
 
837
><TT
 
838
CLASS="LITERAL"
 
839
>LIKE <TT
 
840
CLASS="REPLACEABLE"
 
841
><I
 
842
>parent_table</I
 
843
></TT
 
844
> [ <TT
 
845
CLASS="REPLACEABLE"
 
846
><I
 
847
>like_option</I
 
848
></TT
 
849
> ... ]</TT
 
850
></DT
 
851
><DD
 
852
><P
 
853
>      The <TT
 
854
CLASS="LITERAL"
 
855
>LIKE</TT
 
856
> clause specifies a table from which
 
857
      the new table automatically copies all column names, their data types,
 
858
      and their not-null constraints.
 
859
     </P
 
860
><P
 
861
>      Unlike <TT
 
862
CLASS="LITERAL"
 
863
>INHERITS</TT
 
864
>, the new table and original table
 
865
      are completely decoupled after creation is complete.  Changes to the
 
866
      original table will not be applied to the new table, and it is not
 
867
      possible to include data of the new table in scans of the original
 
868
      table.
 
869
     </P
 
870
><P
 
871
>      Default expressions for the copied column definitions will only be
 
872
      copied if <TT
 
873
CLASS="LITERAL"
 
874
>INCLUDING DEFAULTS</TT
 
875
> is specified.  The
 
876
      default behavior is to exclude default expressions, resulting in the
 
877
      copied columns in the new table having null defaults.
 
878
     </P
 
879
><P
 
880
>      Not-null constraints are always copied to the new table.
 
881
      <TT
 
882
CLASS="LITERAL"
 
883
>CHECK</TT
 
884
> constraints will only be copied if
 
885
      <TT
 
886
CLASS="LITERAL"
 
887
>INCLUDING CONSTRAINTS</TT
 
888
> is specified; other types of
 
889
      constraints will never be copied. Also, no distinction is made between
 
890
      column constraints and table constraints &mdash; when constraints are
 
891
      requested, all check constraints are copied.
 
892
     </P
 
893
><P
 
894
>      Any indexes on the original table will not be created on the new
 
895
      table, unless the <TT
 
896
CLASS="LITERAL"
 
897
>INCLUDING INDEXES</TT
 
898
> clause is
 
899
      specified.
 
900
     </P
 
901
><P
 
902
>      <TT
 
903
CLASS="LITERAL"
 
904
>STORAGE</TT
 
905
> settings for the copied column definitions will only
 
906
      be copied if <TT
 
907
CLASS="LITERAL"
 
908
>INCLUDING STORAGE</TT
 
909
> is specified.  The
 
910
      default behavior is to exclude <TT
 
911
CLASS="LITERAL"
 
912
>STORAGE</TT
 
913
> settings, resulting
 
914
      in the copied columns in the new table having type-specific default
 
915
      settings.  For more on <TT
 
916
CLASS="LITERAL"
 
917
>STORAGE</TT
 
918
> settings, see
 
919
      <A
 
920
HREF="storage-toast.html"
 
921
>Section 55.2</A
 
922
>.
 
923
     </P
 
924
><P
 
925
>      Comments for the copied columns, constraints, and indexes
 
926
      will only be copied if <TT
 
927
CLASS="LITERAL"
 
928
>INCLUDING COMMENTS</TT
 
929
>
 
930
      is specified. The default behavior is to exclude comments, resulting in
 
931
      the copied columns and constraints in the new table having no comments.
 
932
     </P
 
933
><P
 
934
>      <TT
 
935
CLASS="LITERAL"
 
936
>INCLUDING ALL</TT
 
937
> is an abbreviated form of
 
938
      <TT
 
939
CLASS="LITERAL"
 
940
>INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING STORAGE INCLUDING COMMENTS</TT
 
941
>.
 
942
     </P
 
943
><P
 
944
>      Note also that unlike <TT
 
945
CLASS="LITERAL"
 
946
>INHERITS</TT
 
947
>, columns and
 
948
      constraints copied by <TT
 
949
CLASS="LITERAL"
 
950
>LIKE</TT
 
951
> are not merged with similarly
 
952
      named columns and constraints.
 
953
      If the same name is specified explicitly or in another
 
954
      <TT
 
955
CLASS="LITERAL"
 
956
>LIKE</TT
 
957
> clause, an error is signalled.
 
958
     </P
 
959
></DD
 
960
><DT
 
961
><TT
 
962
CLASS="LITERAL"
 
963
>CONSTRAINT <TT
 
964
CLASS="REPLACEABLE"
 
965
><I
 
966
>constraint_name</I
 
967
></TT
 
968
></TT
 
969
></DT
 
970
><DD
 
971
><P
 
972
>      An optional name for a column or table constraint.  If the
 
973
      constraint is violated, the constraint name is present in error messages,
 
974
      so constraint names like <TT
 
975
CLASS="LITERAL"
 
976
>col must be positive</TT
 
977
> can be used
 
978
      to communicate helpful constraint information to client applications.
 
979
      (Double-quotes are needed to specify constraint names that contain spaces.)
 
980
      If a constraint name is not specified, the system generates a name.
 
981
     </P
 
982
></DD
 
983
><DT
 
984
><TT
 
985
CLASS="LITERAL"
 
986
>NOT NULL</TT
 
987
></DT
 
988
><DD
 
989
><P
 
990
>      The column is not allowed to contain null values.
 
991
     </P
 
992
></DD
 
993
><DT
 
994
><TT
 
995
CLASS="LITERAL"
 
996
>NULL</TT
 
997
></DT
 
998
><DD
 
999
><P
 
1000
>      The column is allowed to contain null values. This is the default.
 
1001
     </P
 
1002
><P
 
1003
>      This clause is only provided for compatibility with
 
1004
      non-standard SQL databases.  Its use is discouraged in new
 
1005
      applications.
 
1006
     </P
 
1007
></DD
 
1008
><DT
 
1009
><TT
 
1010
CLASS="LITERAL"
 
1011
>CHECK ( <TT
 
1012
CLASS="REPLACEABLE"
 
1013
><I
 
1014
>expression</I
 
1015
></TT
 
1016
> )</TT
 
1017
></DT
 
1018
><DD
 
1019
><P
 
1020
>      The <TT
 
1021
CLASS="LITERAL"
 
1022
>CHECK</TT
 
1023
> clause specifies an expression producing a
 
1024
      Boolean result which new or updated rows must satisfy for an
 
1025
      insert or update operation to succeed.  Expressions evaluating
 
1026
      to TRUE or UNKNOWN succeed.  Should any row of an insert or
 
1027
      update operation produce a FALSE result an error exception is
 
1028
      raised and the insert or update does not alter the database.  A
 
1029
      check constraint specified as a column constraint should
 
1030
      reference that column's value only, while an expression
 
1031
      appearing in a table constraint can reference multiple columns.
 
1032
     </P
 
1033
><P
 
1034
>      Currently, <TT
 
1035
CLASS="LITERAL"
 
1036
>CHECK</TT
 
1037
> expressions cannot contain
 
1038
      subqueries nor refer to variables other than columns of the
 
1039
      current row.
 
1040
     </P
 
1041
></DD
 
1042
><DT
 
1043
><TT
 
1044
CLASS="LITERAL"
 
1045
>DEFAULT
 
1046
    <TT
 
1047
CLASS="REPLACEABLE"
 
1048
><I
 
1049
>default_expr</I
 
1050
></TT
 
1051
></TT
 
1052
></DT
 
1053
><DD
 
1054
><P
 
1055
>      The <TT
 
1056
CLASS="LITERAL"
 
1057
>DEFAULT</TT
 
1058
> clause assigns a default data value for
 
1059
      the column whose column definition it appears within.  The value
 
1060
      is any variable-free expression (subqueries and cross-references
 
1061
      to other columns in the current table are not allowed).  The
 
1062
      data type of the default expression must match the data type of the
 
1063
      column.
 
1064
     </P
 
1065
><P
 
1066
>      The default expression will be used in any insert operation that
 
1067
      does not specify a value for the column.  If there is no default
 
1068
      for a column, then the default is null.
 
1069
     </P
 
1070
></DD
 
1071
><DT
 
1072
><TT
 
1073
CLASS="LITERAL"
 
1074
>UNIQUE</TT
 
1075
> (column constraint)<BR><TT
 
1076
CLASS="LITERAL"
 
1077
>UNIQUE ( <TT
 
1078
CLASS="REPLACEABLE"
 
1079
><I
 
1080
>column_name</I
 
1081
></TT
 
1082
> [, ... ] )</TT
 
1083
> (table constraint)</DT
 
1084
><DD
 
1085
><P
 
1086
>      The <TT
 
1087
CLASS="LITERAL"
 
1088
>UNIQUE</TT
 
1089
> constraint specifies that a
 
1090
      group of one or more columns of a table can contain
 
1091
      only unique values. The behavior of the unique table constraint
 
1092
      is the same as that for column constraints, with the additional
 
1093
      capability to span multiple columns.
 
1094
     </P
 
1095
><P
 
1096
>      For the purpose of a unique constraint, null values are not
 
1097
      considered equal.
 
1098
     </P
 
1099
><P
 
1100
>      Each unique table constraint must name a set of columns that is
 
1101
      different from the set of columns named by any other unique or
 
1102
      primary key constraint defined for the table.  (Otherwise it
 
1103
      would just be the same constraint listed twice.)
 
1104
     </P
 
1105
></DD
 
1106
><DT
 
1107
><TT
 
1108
CLASS="LITERAL"
 
1109
>PRIMARY KEY</TT
 
1110
> (column constraint)<BR><TT
 
1111
CLASS="LITERAL"
 
1112
>PRIMARY KEY ( <TT
 
1113
CLASS="REPLACEABLE"
 
1114
><I
 
1115
>column_name</I
 
1116
></TT
 
1117
> [, ... ] )</TT
 
1118
> (table constraint)</DT
 
1119
><DD
 
1120
><P
 
1121
>      The primary key constraint specifies that a column or columns of a table
 
1122
      can contain only unique (non-duplicate), nonnull values.
 
1123
      Technically, <TT
 
1124
CLASS="LITERAL"
 
1125
>PRIMARY KEY</TT
 
1126
> is merely a
 
1127
      combination of <TT
 
1128
CLASS="LITERAL"
 
1129
>UNIQUE</TT
 
1130
> and <TT
 
1131
CLASS="LITERAL"
 
1132
>NOT NULL</TT
 
1133
>, but
 
1134
      identifying a set of columns as primary key also provides
 
1135
      metadata about the design of the schema, as a primary key
 
1136
      implies that other tables
 
1137
      can rely on this set of columns as a unique identifier for rows.
 
1138
     </P
 
1139
><P
 
1140
>      Only one primary key can be specified for a table, whether as a
 
1141
      column constraint or a table constraint.
 
1142
     </P
 
1143
><P
 
1144
>      The primary key constraint should name a set of columns that is
 
1145
      different from other sets of columns named by any unique
 
1146
      constraint defined for the same table.
 
1147
     </P
 
1148
></DD
 
1149
><DT
 
1150
><A
 
1151
NAME="SQL-CREATETABLE-EXCLUDE"
 
1152
></A
 
1153
><TT
 
1154
CLASS="LITERAL"
 
1155
>EXCLUDE [ USING <TT
 
1156
CLASS="REPLACEABLE"
 
1157
><I
 
1158
>index_method</I
 
1159
></TT
 
1160
> ] ( <TT
 
1161
CLASS="REPLACEABLE"
 
1162
><I
 
1163
>exclude_element</I
 
1164
></TT
 
1165
> WITH <TT
 
1166
CLASS="REPLACEABLE"
 
1167
><I
 
1168
>operator</I
 
1169
></TT
 
1170
> [, ... ] ) <TT
 
1171
CLASS="REPLACEABLE"
 
1172
><I
 
1173
>index_parameters</I
 
1174
></TT
 
1175
> [ WHERE ( <TT
 
1176
CLASS="REPLACEABLE"
 
1177
><I
 
1178
>predicate</I
 
1179
></TT
 
1180
> ) ]</TT
 
1181
></DT
 
1182
><DD
 
1183
><P
 
1184
>      The <TT
 
1185
CLASS="LITERAL"
 
1186
>EXCLUDE</TT
 
1187
> clause defines an exclusion
 
1188
      constraint, which guarantees that if
 
1189
      any two rows are compared on the specified column(s) or
 
1190
      expression(s) using the specified operator(s), not all of these
 
1191
      comparisons will return <TT
 
1192
CLASS="LITERAL"
 
1193
>TRUE</TT
 
1194
>.  If all of the
 
1195
      specified operators test for equality, this is equivalent to a
 
1196
      <TT
 
1197
CLASS="LITERAL"
 
1198
>UNIQUE</TT
 
1199
> constraint, although an ordinary unique constraint
 
1200
      will be faster.  However, exclusion constraints can specify
 
1201
      constraints that are more general than simple equality.
 
1202
      For example, you can specify a constraint that
 
1203
      no two rows in the table contain overlapping circles
 
1204
      (see <A
 
1205
HREF="datatype-geometric.html"
 
1206
>Section 8.8</A
 
1207
>) by using the
 
1208
      <TT
 
1209
CLASS="LITERAL"
 
1210
>&amp;&amp;</TT
 
1211
> operator.
 
1212
     </P
 
1213
><P
 
1214
>      Exclusion constraints are implemented using
 
1215
      an index, so each specified operator must be associated with an
 
1216
      appropriate operator class
 
1217
      (see <A
 
1218
HREF="indexes-opclass.html"
 
1219
>Section 11.9</A
 
1220
>) for the index access
 
1221
      method <TT
 
1222
CLASS="REPLACEABLE"
 
1223
><I
 
1224
>index_method</I
 
1225
></TT
 
1226
>.
 
1227
      The operators are required to be commutative.
 
1228
      Each <TT
 
1229
CLASS="REPLACEABLE"
 
1230
><I
 
1231
>exclude_element</I
 
1232
></TT
 
1233
>
 
1234
      can optionally specify an operator class and/or ordering options;
 
1235
      these are described fully under
 
1236
      <A
 
1237
HREF="sql-createindex.html"
 
1238
>CREATE INDEX</A
 
1239
>.
 
1240
     </P
 
1241
><P
 
1242
>      The access method must support <TT
 
1243
CLASS="LITERAL"
 
1244
>amgettuple</TT
 
1245
> (see <A
 
1246
HREF="indexam.html"
 
1247
>Chapter 52</A
 
1248
>); at present this means <ACRONYM
 
1249
CLASS="ACRONYM"
 
1250
>GIN</ACRONYM
 
1251
>
 
1252
      cannot be used.  Although it's allowed, there is little point in using
 
1253
      B-tree or hash indexes with an exclusion constraint, because this
 
1254
      does nothing that an ordinary unique constraint doesn't do better.
 
1255
      So in practice the access method will always be <ACRONYM
 
1256
CLASS="ACRONYM"
 
1257
>GiST</ACRONYM
 
1258
>.
 
1259
     </P
 
1260
><P
 
1261
>      The <TT
 
1262
CLASS="REPLACEABLE"
 
1263
><I
 
1264
>predicate</I
 
1265
></TT
 
1266
> allows you to specify an
 
1267
      exclusion constraint on a subset of the table; internally this creates a
 
1268
      partial index. Note that parentheses are required around the predicate.
 
1269
     </P
 
1270
></DD
 
1271
><DT
 
1272
><TT
 
1273
CLASS="LITERAL"
 
1274
>REFERENCES <TT
 
1275
CLASS="REPLACEABLE"
 
1276
><I
 
1277
>reftable</I
 
1278
></TT
 
1279
> [ ( <TT
 
1280
CLASS="REPLACEABLE"
 
1281
><I
 
1282
>refcolumn</I
 
1283
></TT
 
1284
> ) ] [ MATCH <TT
 
1285
CLASS="REPLACEABLE"
 
1286
><I
 
1287
>matchtype</I
 
1288
></TT
 
1289
> ] [ ON DELETE <TT
 
1290
CLASS="REPLACEABLE"
 
1291
><I
 
1292
>action</I
 
1293
></TT
 
1294
> ] [ ON UPDATE <TT
 
1295
CLASS="REPLACEABLE"
 
1296
><I
 
1297
>action</I
 
1298
></TT
 
1299
> ]</TT
 
1300
> (column constraint)<BR><TT
 
1301
CLASS="LITERAL"
 
1302
>FOREIGN KEY ( <TT
 
1303
CLASS="REPLACEABLE"
 
1304
><I
 
1305
>column</I
 
1306
></TT
 
1307
> [, ... ] )
 
1308
    REFERENCES <TT
 
1309
CLASS="REPLACEABLE"
 
1310
><I
 
1311
>reftable</I
 
1312
></TT
 
1313
> [ ( <TT
 
1314
CLASS="REPLACEABLE"
 
1315
><I
 
1316
>refcolumn</I
 
1317
></TT
 
1318
> [, ... ] ) ]
 
1319
    [ MATCH <TT
 
1320
CLASS="REPLACEABLE"
 
1321
><I
 
1322
>matchtype</I
 
1323
></TT
 
1324
> ]
 
1325
    [ ON DELETE <TT
 
1326
CLASS="REPLACEABLE"
 
1327
><I
 
1328
>action</I
 
1329
></TT
 
1330
> ]
 
1331
    [ ON UPDATE <TT
 
1332
CLASS="REPLACEABLE"
 
1333
><I
 
1334
>action</I
 
1335
></TT
 
1336
> ]</TT
 
1337
>
 
1338
    (table constraint)</DT
 
1339
><DD
 
1340
><P
 
1341
>      These clauses specify a foreign key constraint, which requires
 
1342
      that a group of one or more columns of the new table must only
 
1343
      contain values that match values in the referenced
 
1344
      column(s) of some row of the referenced table.  If <TT
 
1345
CLASS="REPLACEABLE"
 
1346
><I
 
1347
>refcolumn</I
 
1348
></TT
 
1349
> is omitted, the
 
1350
      primary key of the <TT
 
1351
CLASS="REPLACEABLE"
 
1352
><I
 
1353
>reftable</I
 
1354
></TT
 
1355
>
 
1356
      is used.  The referenced columns must be the columns of a non-deferrable
 
1357
      unique or primary key constraint in the referenced table.  Note that
 
1358
      foreign key constraints cannot be defined between temporary tables and
 
1359
      permanent tables.
 
1360
     </P
 
1361
><P
 
1362
>      A value inserted into the referencing column(s) is matched against the
 
1363
      values of the referenced table and referenced columns using the
 
1364
      given match type.  There are three match types: <TT
 
1365
CLASS="LITERAL"
 
1366
>MATCH
 
1367
      FULL</TT
 
1368
>, <TT
 
1369
CLASS="LITERAL"
 
1370
>MATCH PARTIAL</TT
 
1371
>, and <TT
 
1372
CLASS="LITERAL"
 
1373
>MATCH
 
1374
      SIMPLE</TT
 
1375
>, which is also the default.  <TT
 
1376
CLASS="LITERAL"
 
1377
>MATCH
 
1378
      FULL</TT
 
1379
> will not allow one column of a multicolumn foreign key
 
1380
      to be null unless all foreign key columns are null.
 
1381
      <TT
 
1382
CLASS="LITERAL"
 
1383
>MATCH SIMPLE</TT
 
1384
> allows some foreign key columns
 
1385
      to be null while other parts of the foreign key are not
 
1386
      null. <TT
 
1387
CLASS="LITERAL"
 
1388
>MATCH PARTIAL</TT
 
1389
> is not yet implemented.
 
1390
     </P
 
1391
><P
 
1392
>      In addition, when the data in the referenced columns is changed,
 
1393
      certain actions are performed on the data in this table's
 
1394
      columns.  The <TT
 
1395
CLASS="LITERAL"
 
1396
>ON DELETE</TT
 
1397
> clause specifies the
 
1398
      action to perform when a referenced row in the referenced table is
 
1399
      being deleted.  Likewise, the <TT
 
1400
CLASS="LITERAL"
 
1401
>ON UPDATE</TT
 
1402
>
 
1403
      clause specifies the action to perform when a referenced column
 
1404
      in the referenced table is being updated to a new value. If the
 
1405
      row is updated, but the referenced column is not actually
 
1406
      changed, no action is done. Referential actions other than the
 
1407
      <TT
 
1408
CLASS="LITERAL"
 
1409
>NO ACTION</TT
 
1410
> check cannot be deferred, even if
 
1411
      the constraint is declared deferrable. There are the following possible
 
1412
      actions for each clause:
 
1413
 
 
1414
      <P
 
1415
></P
 
1416
></P><DIV
 
1417
CLASS="VARIABLELIST"
 
1418
><DL
 
1419
><DT
 
1420
><TT
 
1421
CLASS="LITERAL"
 
1422
>NO ACTION</TT
 
1423
></DT
 
1424
><DD
 
1425
><P
 
1426
>          Produce an error indicating that the deletion or update
 
1427
          would create a foreign key constraint violation.
 
1428
          If the constraint is deferred, this
 
1429
          error will be produced at constraint check time if there still
 
1430
          exist any referencing rows.  This is the default action.
 
1431
         </P
 
1432
></DD
 
1433
><DT
 
1434
><TT
 
1435
CLASS="LITERAL"
 
1436
>RESTRICT</TT
 
1437
></DT
 
1438
><DD
 
1439
><P
 
1440
>          Produce an error indicating that the deletion or update
 
1441
          would create a foreign key constraint violation.
 
1442
          This is the same as <TT
 
1443
CLASS="LITERAL"
 
1444
>NO ACTION</TT
 
1445
> except that
 
1446
          the check is not deferrable.
 
1447
         </P
 
1448
></DD
 
1449
><DT
 
1450
><TT
 
1451
CLASS="LITERAL"
 
1452
>CASCADE</TT
 
1453
></DT
 
1454
><DD
 
1455
><P
 
1456
>          Delete any rows referencing the deleted row, or update the
 
1457
          value of the referencing column to the new value of the
 
1458
          referenced column, respectively.
 
1459
         </P
 
1460
></DD
 
1461
><DT
 
1462
><TT
 
1463
CLASS="LITERAL"
 
1464
>SET NULL</TT
 
1465
></DT
 
1466
><DD
 
1467
><P
 
1468
>          Set the referencing column(s) to null.
 
1469
         </P
 
1470
></DD
 
1471
><DT
 
1472
><TT
 
1473
CLASS="LITERAL"
 
1474
>SET DEFAULT</TT
 
1475
></DT
 
1476
><DD
 
1477
><P
 
1478
>          Set the referencing column(s) to their default values.
 
1479
         </P
 
1480
></DD
 
1481
></DL
 
1482
></DIV
 
1483
><P>
 
1484
     </P
 
1485
><P
 
1486
>      If the referenced column(s) are changed frequently, it might be wise to
 
1487
      add an index to the foreign key column so that referential actions
 
1488
      associated with the foreign key column can be performed more
 
1489
      efficiently.
 
1490
     </P
 
1491
></DD
 
1492
><DT
 
1493
><TT
 
1494
CLASS="LITERAL"
 
1495
>DEFERRABLE</TT
 
1496
><BR><TT
 
1497
CLASS="LITERAL"
 
1498
>NOT DEFERRABLE</TT
 
1499
></DT
 
1500
><DD
 
1501
><P
 
1502
>      This controls whether the constraint can be deferred.  A
 
1503
      constraint that is not deferrable will be checked immediately
 
1504
      after every command.  Checking of constraints that are
 
1505
      deferrable can be postponed until the end of the transaction
 
1506
      (using the <A
 
1507
HREF="sql-set-constraints.html"
 
1508
>SET CONSTRAINTS</A
 
1509
> command).
 
1510
      <TT
 
1511
CLASS="LITERAL"
 
1512
>NOT DEFERRABLE</TT
 
1513
> is the default.
 
1514
      Currently, only <TT
 
1515
CLASS="LITERAL"
 
1516
>UNIQUE</TT
 
1517
>, <TT
 
1518
CLASS="LITERAL"
 
1519
>PRIMARY KEY</TT
 
1520
>,
 
1521
      <TT
 
1522
CLASS="LITERAL"
 
1523
>EXCLUDE</TT
 
1524
>, and
 
1525
      <TT
 
1526
CLASS="LITERAL"
 
1527
>REFERENCES</TT
 
1528
> (foreign key) constraints accept this
 
1529
      clause.  <TT
 
1530
CLASS="LITERAL"
 
1531
>NOT NULL</TT
 
1532
> and <TT
 
1533
CLASS="LITERAL"
 
1534
>CHECK</TT
 
1535
> constraints are not
 
1536
      deferrable.
 
1537
     </P
 
1538
></DD
 
1539
><DT
 
1540
><TT
 
1541
CLASS="LITERAL"
 
1542
>INITIALLY IMMEDIATE</TT
 
1543
><BR><TT
 
1544
CLASS="LITERAL"
 
1545
>INITIALLY DEFERRED</TT
 
1546
></DT
 
1547
><DD
 
1548
><P
 
1549
>      If a constraint is deferrable, this clause specifies the default
 
1550
      time to check the constraint.  If the constraint is
 
1551
      <TT
 
1552
CLASS="LITERAL"
 
1553
>INITIALLY IMMEDIATE</TT
 
1554
>, it is checked after each
 
1555
      statement. This is the default.  If the constraint is
 
1556
      <TT
 
1557
CLASS="LITERAL"
 
1558
>INITIALLY DEFERRED</TT
 
1559
>, it is checked only at the
 
1560
      end of the transaction.  The constraint check time can be
 
1561
      altered with the <A
 
1562
HREF="sql-set-constraints.html"
 
1563
>SET CONSTRAINTS</A
 
1564
> command.
 
1565
     </P
 
1566
></DD
 
1567
><DT
 
1568
><TT
 
1569
CLASS="LITERAL"
 
1570
>WITH ( <TT
 
1571
CLASS="REPLACEABLE"
 
1572
><I
 
1573
>storage_parameter</I
 
1574
></TT
 
1575
> [= <TT
 
1576
CLASS="REPLACEABLE"
 
1577
><I
 
1578
>value</I
 
1579
></TT
 
1580
>] [, ... ] )</TT
 
1581
></DT
 
1582
><DD
 
1583
><P
 
1584
>      This clause specifies optional storage parameters for a table or index;
 
1585
      see <A
 
1586
HREF="sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS"
 
1587
><I
 
1588
>Storage Parameters</I
 
1589
></A
 
1590
> for more
 
1591
      information.  The <TT
 
1592
CLASS="LITERAL"
 
1593
>WITH</TT
 
1594
> clause for a
 
1595
      table can also include <TT
 
1596
CLASS="LITERAL"
 
1597
>OIDS=TRUE</TT
 
1598
> (or just <TT
 
1599
CLASS="LITERAL"
 
1600
>OIDS</TT
 
1601
>)
 
1602
      to specify that rows of the new table
 
1603
      should have OIDs (object identifiers) assigned to them, or
 
1604
      <TT
 
1605
CLASS="LITERAL"
 
1606
>OIDS=FALSE</TT
 
1607
> to specify that the rows should not have OIDs.
 
1608
      If <TT
 
1609
CLASS="LITERAL"
 
1610
>OIDS</TT
 
1611
> is not specified, the default setting depends upon
 
1612
      the <A
 
1613
HREF="runtime-config-compatible.html#GUC-DEFAULT-WITH-OIDS"
 
1614
>default_with_oids</A
 
1615
> configuration parameter.
 
1616
      (If the new table inherits from any tables that have OIDs, then
 
1617
      <TT
 
1618
CLASS="LITERAL"
 
1619
>OIDS=TRUE</TT
 
1620
> is forced even if the command says
 
1621
      <TT
 
1622
CLASS="LITERAL"
 
1623
>OIDS=FALSE</TT
 
1624
>.)
 
1625
     </P
 
1626
><P
 
1627
>      If <TT
 
1628
CLASS="LITERAL"
 
1629
>OIDS=FALSE</TT
 
1630
> is specified or implied, the new
 
1631
      table does not store OIDs and no OID will be assigned for a row inserted
 
1632
      into it. This is generally considered worthwhile, since it
 
1633
      will reduce OID consumption and thereby postpone the wraparound
 
1634
      of the 32-bit OID counter. Once the counter wraps around, OIDs
 
1635
      can no longer be assumed to be unique, which makes them
 
1636
      considerably less useful. In addition, excluding OIDs from a
 
1637
      table reduces the space required to store the table on disk by
 
1638
      4 bytes per row (on most machines), slightly improving performance.
 
1639
     </P
 
1640
><P
 
1641
>      To remove OIDs from a table after it has been created, use <A
 
1642
HREF="sql-altertable.html"
 
1643
>ALTER TABLE</A
 
1644
>.
 
1645
     </P
 
1646
></DD
 
1647
><DT
 
1648
><TT
 
1649
CLASS="LITERAL"
 
1650
>WITH OIDS</TT
 
1651
><BR><TT
 
1652
CLASS="LITERAL"
 
1653
>WITHOUT OIDS</TT
 
1654
></DT
 
1655
><DD
 
1656
><P
 
1657
>      These are obsolescent syntaxes equivalent to <TT
 
1658
CLASS="LITERAL"
 
1659
>WITH (OIDS)</TT
 
1660
>
 
1661
      and <TT
 
1662
CLASS="LITERAL"
 
1663
>WITH (OIDS=FALSE)</TT
 
1664
>, respectively.  If you wish to give
 
1665
      both an <TT
 
1666
CLASS="LITERAL"
 
1667
>OIDS</TT
 
1668
> setting and storage parameters, you must use
 
1669
      the <TT
 
1670
CLASS="LITERAL"
 
1671
>WITH ( ... )</TT
 
1672
> syntax; see above.
 
1673
     </P
 
1674
></DD
 
1675
><DT
 
1676
><TT
 
1677
CLASS="LITERAL"
 
1678
>ON COMMIT</TT
 
1679
></DT
 
1680
><DD
 
1681
><P
 
1682
>      The behavior of temporary tables at the end of a transaction
 
1683
      block can be controlled using <TT
 
1684
CLASS="LITERAL"
 
1685
>ON COMMIT</TT
 
1686
>.
 
1687
      The three options are:
 
1688
 
 
1689
      <P
 
1690
></P
 
1691
></P><DIV
 
1692
CLASS="VARIABLELIST"
 
1693
><DL
 
1694
><DT
 
1695
><TT
 
1696
CLASS="LITERAL"
 
1697
>PRESERVE ROWS</TT
 
1698
></DT
 
1699
><DD
 
1700
><P
 
1701
>          No special action is taken at the ends of transactions.
 
1702
          This is the default behavior.
 
1703
         </P
 
1704
></DD
 
1705
><DT
 
1706
><TT
 
1707
CLASS="LITERAL"
 
1708
>DELETE ROWS</TT
 
1709
></DT
 
1710
><DD
 
1711
><P
 
1712
>          All rows in the temporary table will be deleted at the end
 
1713
          of each transaction block.  Essentially, an automatic <A
 
1714
HREF="sql-truncate.html"
 
1715
>TRUNCATE</A
 
1716
> is done
 
1717
          at each commit.
 
1718
         </P
 
1719
></DD
 
1720
><DT
 
1721
><TT
 
1722
CLASS="LITERAL"
 
1723
>DROP</TT
 
1724
></DT
 
1725
><DD
 
1726
><P
 
1727
>          The temporary table will be dropped at the end of the current
 
1728
          transaction block.
 
1729
         </P
 
1730
></DD
 
1731
></DL
 
1732
></DIV
 
1733
><P>
 
1734
     </P
 
1735
></DD
 
1736
><DT
 
1737
><TT
 
1738
CLASS="LITERAL"
 
1739
>TABLESPACE <TT
 
1740
CLASS="REPLACEABLE"
 
1741
><I
 
1742
>tablespace</I
 
1743
></TT
 
1744
></TT
 
1745
></DT
 
1746
><DD
 
1747
><P
 
1748
>      The <TT
 
1749
CLASS="REPLACEABLE"
 
1750
><I
 
1751
>tablespace</I
 
1752
></TT
 
1753
> is the name
 
1754
      of the tablespace in which the new table is to be created.
 
1755
      If not specified,
 
1756
      <A
 
1757
HREF="runtime-config-client.html#GUC-DEFAULT-TABLESPACE"
 
1758
>default_tablespace</A
 
1759
> is consulted, or
 
1760
      <A
 
1761
HREF="runtime-config-client.html#GUC-TEMP-TABLESPACES"
 
1762
>temp_tablespaces</A
 
1763
> if the table is temporary.
 
1764
     </P
 
1765
></DD
 
1766
><DT
 
1767
><TT
 
1768
CLASS="LITERAL"
 
1769
>USING INDEX TABLESPACE <TT
 
1770
CLASS="REPLACEABLE"
 
1771
><I
 
1772
>tablespace</I
 
1773
></TT
 
1774
></TT
 
1775
></DT
 
1776
><DD
 
1777
><P
 
1778
>      This clause allows selection of the tablespace in which the index
 
1779
      associated with a <TT
 
1780
CLASS="LITERAL"
 
1781
>UNIQUE</TT
 
1782
>, <TT
 
1783
CLASS="LITERAL"
 
1784
>PRIMARY
 
1785
      KEY</TT
 
1786
>, or <TT
 
1787
CLASS="LITERAL"
 
1788
>EXCLUDE</TT
 
1789
> constraint will be created.
 
1790
      If not specified,
 
1791
      <A
 
1792
HREF="runtime-config-client.html#GUC-DEFAULT-TABLESPACE"
 
1793
>default_tablespace</A
 
1794
> is consulted, or
 
1795
      <A
 
1796
HREF="runtime-config-client.html#GUC-TEMP-TABLESPACES"
 
1797
>temp_tablespaces</A
 
1798
> if the table is temporary.
 
1799
     </P
 
1800
></DD
 
1801
></DL
 
1802
></DIV
 
1803
><DIV
 
1804
CLASS="REFSECT2"
 
1805
><A
 
1806
NAME="SQL-CREATETABLE-STORAGE-PARAMETERS"
 
1807
></A
 
1808
><H3
 
1809
>Storage Parameters</H3
 
1810
><P
 
1811
>    The <TT
 
1812
CLASS="LITERAL"
 
1813
>WITH</TT
 
1814
> clause can specify <I
 
1815
CLASS="FIRSTTERM"
 
1816
>storage parameters</I
 
1817
>
 
1818
    for tables, and for indexes associated with a <TT
 
1819
CLASS="LITERAL"
 
1820
>UNIQUE</TT
 
1821
>,
 
1822
    <TT
 
1823
CLASS="LITERAL"
 
1824
>PRIMARY KEY</TT
 
1825
>, or <TT
 
1826
CLASS="LITERAL"
 
1827
>EXCLUDE</TT
 
1828
> constraint.
 
1829
    Storage parameters for
 
1830
    indexes are documented in <A
 
1831
HREF="sql-createindex.html"
 
1832
>CREATE INDEX</A
 
1833
>.
 
1834
    The storage parameters currently
 
1835
    available for tables are listed below.  For each parameter, unless noted,
 
1836
    there is an additional parameter with the same name prefixed with
 
1837
    <TT
 
1838
CLASS="LITERAL"
 
1839
>toast.</TT
 
1840
>, which can be used to control the behavior of the
 
1841
    table's secondary <ACRONYM
 
1842
CLASS="ACRONYM"
 
1843
>TOAST</ACRONYM
 
1844
> table, if any
 
1845
    (see <A
 
1846
HREF="storage-toast.html"
 
1847
>Section 55.2</A
 
1848
> for more information about TOAST).
 
1849
    Note that the TOAST table inherits the
 
1850
    <TT
 
1851
CLASS="LITERAL"
 
1852
>autovacuum_*</TT
 
1853
> values from its parent table, if there are
 
1854
    no <TT
 
1855
CLASS="LITERAL"
 
1856
>toast.autovacuum_*</TT
 
1857
> settings set.
 
1858
   </P
 
1859
><P
 
1860
></P
 
1861
><DIV
 
1862
CLASS="VARIABLELIST"
 
1863
><DL
 
1864
><DT
 
1865
><TT
 
1866
CLASS="LITERAL"
 
1867
>fillfactor</TT
 
1868
> (<TT
 
1869
CLASS="TYPE"
 
1870
>integer</TT
 
1871
>)</DT
 
1872
><DD
 
1873
><P
 
1874
>      The fillfactor for a table is a percentage between 10 and 100.
 
1875
      100 (complete packing) is the default.  When a smaller fillfactor
 
1876
      is specified, <TT
 
1877
CLASS="COMMAND"
 
1878
>INSERT</TT
 
1879
> operations pack table pages only
 
1880
      to the indicated percentage; the remaining space on each page is
 
1881
      reserved for updating rows on that page.  This gives <TT
 
1882
CLASS="COMMAND"
 
1883
>UPDATE</TT
 
1884
>
 
1885
      a chance to place the updated copy of a row on the same page as the
 
1886
      original, which is more efficient than placing it on a different page.
 
1887
      For a table whose entries are never updated, complete packing is the
 
1888
      best choice, but in heavily updated tables smaller fillfactors are
 
1889
      appropriate.  This parameter cannot be set for TOAST tables.
 
1890
     </P
 
1891
></DD
 
1892
><DT
 
1893
><TT
 
1894
CLASS="LITERAL"
 
1895
>autovacuum_enabled</TT
 
1896
>, <TT
 
1897
CLASS="LITERAL"
 
1898
>toast.autovacuum_enabled</TT
 
1899
> (<TT
 
1900
CLASS="TYPE"
 
1901
>boolean</TT
 
1902
>)</DT
 
1903
><DD
 
1904
><P
 
1905
>     Enables or disables the autovacuum daemon on a particular table.
 
1906
     If true, the autovacuum daemon will initiate a <TT
 
1907
CLASS="COMMAND"
 
1908
>VACUUM</TT
 
1909
> operation
 
1910
     on a particular table when the number of updated or deleted tuples exceeds
 
1911
     <TT
 
1912
CLASS="LITERAL"
 
1913
>autovacuum_vacuum_threshold</TT
 
1914
> plus
 
1915
     <TT
 
1916
CLASS="LITERAL"
 
1917
>autovacuum_vacuum_scale_factor</TT
 
1918
> times the number of live tuples
 
1919
     currently estimated to be in the relation.
 
1920
     Similarly, it will initiate an <TT
 
1921
CLASS="COMMAND"
 
1922
>ANALYZE</TT
 
1923
> operation when the
 
1924
     number of inserted, updated or deleted tuples exceeds
 
1925
     <TT
 
1926
CLASS="LITERAL"
 
1927
>autovacuum_analyze_threshold</TT
 
1928
> plus
 
1929
     <TT
 
1930
CLASS="LITERAL"
 
1931
>autovacuum_analyze_scale_factor</TT
 
1932
> times the number of live tuples
 
1933
     currently estimated to be in the relation.
 
1934
     If false, this table will not be autovacuumed, except to prevent
 
1935
     transaction Id wraparound. See <A
 
1936
HREF="routine-vacuuming.html#VACUUM-FOR-WRAPAROUND"
 
1937
>Section 23.1.4</A
 
1938
> for
 
1939
     more about wraparound prevention.
 
1940
     Observe that this variable inherits its value from the <A
 
1941
HREF="runtime-config-autovacuum.html#GUC-AUTOVACUUM"
 
1942
>autovacuum</A
 
1943
> setting.
 
1944
     </P
 
1945
></DD
 
1946
><DT
 
1947
><TT
 
1948
CLASS="LITERAL"
 
1949
>autovacuum_vacuum_threshold</TT
 
1950
>, <TT
 
1951
CLASS="LITERAL"
 
1952
>toast.autovacuum_vacuum_threshold</TT
 
1953
> (<TT
 
1954
CLASS="TYPE"
 
1955
>integer</TT
 
1956
>)</DT
 
1957
><DD
 
1958
><P
 
1959
>     Minimum number of updated or deleted tuples before initiate a
 
1960
     <TT
 
1961
CLASS="COMMAND"
 
1962
>VACUUM</TT
 
1963
> operation on a particular table.
 
1964
     </P
 
1965
></DD
 
1966
><DT
 
1967
><TT
 
1968
CLASS="LITERAL"
 
1969
>autovacuum_vacuum_scale_factor</TT
 
1970
>, <TT
 
1971
CLASS="LITERAL"
 
1972
>toast.autovacuum_vacuum_scale_factor</TT
 
1973
> (<TT
 
1974
CLASS="TYPE"
 
1975
>float4</TT
 
1976
>)</DT
 
1977
><DD
 
1978
><P
 
1979
>     Multiplier for <TT
 
1980
CLASS="STRUCTFIELD"
 
1981
>reltuples</TT
 
1982
> to add to
 
1983
     <TT
 
1984
CLASS="LITERAL"
 
1985
>autovacuum_vacuum_threshold</TT
 
1986
>.
 
1987
     </P
 
1988
></DD
 
1989
><DT
 
1990
><TT
 
1991
CLASS="LITERAL"
 
1992
>autovacuum_analyze_threshold</TT
 
1993
> (<TT
 
1994
CLASS="TYPE"
 
1995
>integer</TT
 
1996
>)</DT
 
1997
><DD
 
1998
><P
 
1999
>     Minimum number of inserted, updated, or deleted tuples before initiate an
 
2000
     <TT
 
2001
CLASS="COMMAND"
 
2002
>ANALYZE</TT
 
2003
> operation on a particular table.
 
2004
     </P
 
2005
></DD
 
2006
><DT
 
2007
><TT
 
2008
CLASS="LITERAL"
 
2009
>autovacuum_analyze_scale_factor</TT
 
2010
> (<TT
 
2011
CLASS="TYPE"
 
2012
>float4</TT
 
2013
>)</DT
 
2014
><DD
 
2015
><P
 
2016
>     Multiplier for <TT
 
2017
CLASS="STRUCTFIELD"
 
2018
>reltuples</TT
 
2019
> to add to
 
2020
     <TT
 
2021
CLASS="LITERAL"
 
2022
>autovacuum_analyze_threshold</TT
 
2023
>.
 
2024
     </P
 
2025
></DD
 
2026
><DT
 
2027
><TT
 
2028
CLASS="LITERAL"
 
2029
>autovacuum_vacuum_cost_delay</TT
 
2030
>, <TT
 
2031
CLASS="LITERAL"
 
2032
>toast.autovacuum_vacuum_cost_delay</TT
 
2033
> (<TT
 
2034
CLASS="TYPE"
 
2035
>integer</TT
 
2036
>)</DT
 
2037
><DD
 
2038
><P
 
2039
>     Custom <A
 
2040
HREF="runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY"
 
2041
>autovacuum_vacuum_cost_delay</A
 
2042
> parameter.
 
2043
     </P
 
2044
></DD
 
2045
><DT
 
2046
><TT
 
2047
CLASS="LITERAL"
 
2048
>autovacuum_vacuum_cost_limit</TT
 
2049
>, <TT
 
2050
CLASS="LITERAL"
 
2051
>toast.autovacuum_vacuum_cost_limit</TT
 
2052
> (<TT
 
2053
CLASS="TYPE"
 
2054
>integer</TT
 
2055
>)</DT
 
2056
><DD
 
2057
><P
 
2058
>     Custom <A
 
2059
HREF="runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT"
 
2060
>autovacuum_vacuum_cost_limit</A
 
2061
> parameter.
 
2062
     </P
 
2063
></DD
 
2064
><DT
 
2065
><TT
 
2066
CLASS="LITERAL"
 
2067
>autovacuum_freeze_min_age</TT
 
2068
>, <TT
 
2069
CLASS="LITERAL"
 
2070
>toast.autovacuum_freeze_min_age</TT
 
2071
> (<TT
 
2072
CLASS="TYPE"
 
2073
>integer</TT
 
2074
>)</DT
 
2075
><DD
 
2076
><P
 
2077
>     Custom <A
 
2078
HREF="runtime-config-client.html#GUC-VACUUM-FREEZE-MIN-AGE"
 
2079
>vacuum_freeze_min_age</A
 
2080
> parameter. Note that
 
2081
     autovacuum will ignore attempts to set a per-table
 
2082
     <TT
 
2083
CLASS="LITERAL"
 
2084
>autovacuum_freeze_min_age</TT
 
2085
> larger than the half system-wide
 
2086
     <A
 
2087
HREF="runtime-config-autovacuum.html#GUC-AUTOVACUUM-FREEZE-MAX-AGE"
 
2088
>autovacuum_freeze_max_age</A
 
2089
> setting.
 
2090
     </P
 
2091
></DD
 
2092
><DT
 
2093
><TT
 
2094
CLASS="LITERAL"
 
2095
>autovacuum_freeze_max_age</TT
 
2096
>, <TT
 
2097
CLASS="LITERAL"
 
2098
>toast.autovacuum_freeze_max_age</TT
 
2099
> (<TT
 
2100
CLASS="TYPE"
 
2101
>integer</TT
 
2102
>)</DT
 
2103
><DD
 
2104
><P
 
2105
>     Custom <A
 
2106
HREF="runtime-config-autovacuum.html#GUC-AUTOVACUUM-FREEZE-MAX-AGE"
 
2107
>autovacuum_freeze_max_age</A
 
2108
> parameter. Note that
 
2109
     autovacuum will ignore attempts to set a per-table
 
2110
     <TT
 
2111
CLASS="LITERAL"
 
2112
>autovacuum_freeze_max_age</TT
 
2113
> larger than the system-wide setting
 
2114
     (it can only be set smaller). Note that while you can set
 
2115
     <TT
 
2116
CLASS="LITERAL"
 
2117
>autovacuum_freeze_max_age</TT
 
2118
> very small, or even zero, this is
 
2119
     usually unwise since it will force frequent vacuuming.
 
2120
     </P
 
2121
></DD
 
2122
><DT
 
2123
><TT
 
2124
CLASS="LITERAL"
 
2125
>autovacuum_freeze_table_age</TT
 
2126
>, <TT
 
2127
CLASS="LITERAL"
 
2128
>toast.autovacuum_freeze_table_age</TT
 
2129
> (<TT
 
2130
CLASS="TYPE"
 
2131
>integer</TT
 
2132
>)</DT
 
2133
><DD
 
2134
><P
 
2135
>      Custom <A
 
2136
HREF="runtime-config-client.html#GUC-VACUUM-FREEZE-TABLE-AGE"
 
2137
>vacuum_freeze_table_age</A
 
2138
> parameter.
 
2139
     </P
 
2140
></DD
 
2141
></DL
 
2142
></DIV
 
2143
></DIV
 
2144
></DIV
 
2145
><DIV
 
2146
CLASS="REFSECT1"
 
2147
><A
 
2148
NAME="SQL-CREATETABLE-NOTES"
 
2149
></A
 
2150
><H2
 
2151
>Notes</H2
 
2152
><P
 
2153
>     Using OIDs in new applications is not recommended: where
 
2154
     possible, using a <TT
 
2155
CLASS="LITERAL"
 
2156
>SERIAL</TT
 
2157
> or other sequence
 
2158
     generator as the table's primary key is preferred. However, if
 
2159
     your application does make use of OIDs to identify specific
 
2160
     rows of a table, it is recommended to create a unique constraint
 
2161
     on the <TT
 
2162
CLASS="STRUCTFIELD"
 
2163
>oid</TT
 
2164
> column of that table, to ensure that
 
2165
     OIDs in the table will indeed uniquely identify rows even after
 
2166
     counter wraparound.  Avoid assuming that OIDs are unique across
 
2167
     tables; if you need a database-wide unique identifier, use the
 
2168
     combination of <TT
 
2169
CLASS="STRUCTFIELD"
 
2170
>tableoid</TT
 
2171
> and row OID for the
 
2172
     purpose.
 
2173
    </P
 
2174
><DIV
 
2175
CLASS="TIP"
 
2176
><BLOCKQUOTE
 
2177
CLASS="TIP"
 
2178
><P
 
2179
><B
 
2180
>Tip: </B
 
2181
>      The use of <TT
 
2182
CLASS="LITERAL"
 
2183
>OIDS=FALSE</TT
 
2184
> is not recommended
 
2185
      for tables with no primary key, since without either an OID or a
 
2186
      unique data key, it is difficult to identify specific rows.
 
2187
     </P
 
2188
></BLOCKQUOTE
 
2189
></DIV
 
2190
><P
 
2191
>     <SPAN
 
2192
CLASS="PRODUCTNAME"
 
2193
>PostgreSQL</SPAN
 
2194
> automatically creates an
 
2195
     index for each unique constraint and primary key constraint to
 
2196
     enforce uniqueness.  Thus, it is not necessary to create an
 
2197
     index explicitly for primary key columns.  (See <A
 
2198
HREF="sql-createindex.html"
 
2199
>CREATE INDEX</A
 
2200
> for more information.)
 
2201
    </P
 
2202
><P
 
2203
>     Unique constraints and primary keys are not inherited in the
 
2204
     current implementation.  This makes the combination of
 
2205
     inheritance and unique constraints rather dysfunctional.
 
2206
    </P
 
2207
><P
 
2208
>     A table cannot have more than 1600 columns.  (In practice, the
 
2209
     effective limit is usually lower because of tuple-length constraints.)
 
2210
    </P
 
2211
></DIV
 
2212
><DIV
 
2213
CLASS="REFSECT1"
 
2214
><A
 
2215
NAME="SQL-CREATETABLE-EXAMPLES"
 
2216
></A
 
2217
><H2
 
2218
>Examples</H2
 
2219
><P
 
2220
>   Create table <TT
 
2221
CLASS="STRUCTNAME"
 
2222
>films</TT
 
2223
> and table
 
2224
   <TT
 
2225
CLASS="STRUCTNAME"
 
2226
>distributors</TT
 
2227
>:
 
2228
 
 
2229
</P><PRE
 
2230
CLASS="PROGRAMLISTING"
 
2231
>CREATE TABLE films (
 
2232
    code        char(5) CONSTRAINT firstkey PRIMARY KEY,
 
2233
    title       varchar(40) NOT NULL,
 
2234
    did         integer NOT NULL,
 
2235
    date_prod   date,
 
2236
    kind        varchar(10),
 
2237
    len         interval hour to minute
 
2238
);</PRE
 
2239
><P>
 
2240
 
 
2241
</P><PRE
 
2242
CLASS="PROGRAMLISTING"
 
2243
>CREATE TABLE distributors (
 
2244
     did    integer PRIMARY KEY DEFAULT nextval('serial'),
 
2245
     name   varchar(40) NOT NULL CHECK (name &lt;&gt; '')
 
2246
);</PRE
 
2247
><P>
 
2248
  </P
 
2249
><P
 
2250
>   Create a table with a 2-dimensional array:
 
2251
 
 
2252
</P><PRE
 
2253
CLASS="PROGRAMLISTING"
 
2254
>CREATE TABLE array_int (
 
2255
    vector  int[][]
 
2256
);</PRE
 
2257
><P>
 
2258
  </P
 
2259
><P
 
2260
>   Define a unique table constraint for the table
 
2261
   <TT
 
2262
CLASS="LITERAL"
 
2263
>films</TT
 
2264
>.  Unique table constraints can be defined
 
2265
   on one or more columns of the table:
 
2266
 
 
2267
</P><PRE
 
2268
CLASS="PROGRAMLISTING"
 
2269
>CREATE TABLE films (
 
2270
    code        char(5),
 
2271
    title       varchar(40),
 
2272
    did         integer,
 
2273
    date_prod   date,
 
2274
    kind        varchar(10),
 
2275
    len         interval hour to minute,
 
2276
    CONSTRAINT production UNIQUE(date_prod)
 
2277
);</PRE
 
2278
><P>
 
2279
  </P
 
2280
><P
 
2281
>   Define a check column constraint:
 
2282
 
 
2283
</P><PRE
 
2284
CLASS="PROGRAMLISTING"
 
2285
>CREATE TABLE distributors (
 
2286
    did     integer CHECK (did &gt; 100),
 
2287
    name    varchar(40)
 
2288
);</PRE
 
2289
><P>
 
2290
  </P
 
2291
><P
 
2292
>   Define a check table constraint:
 
2293
 
 
2294
</P><PRE
 
2295
CLASS="PROGRAMLISTING"
 
2296
>CREATE TABLE distributors (
 
2297
    did     integer,
 
2298
    name    varchar(40)
 
2299
    CONSTRAINT con1 CHECK (did &gt; 100 AND name &lt;&gt; '')
 
2300
);</PRE
 
2301
><P>
 
2302
  </P
 
2303
><P
 
2304
>   Define a primary key table constraint for the table
 
2305
   <TT
 
2306
CLASS="STRUCTNAME"
 
2307
>films</TT
 
2308
>:
 
2309
 
 
2310
</P><PRE
 
2311
CLASS="PROGRAMLISTING"
 
2312
>CREATE TABLE films (
 
2313
    code        char(5),
 
2314
    title       varchar(40),
 
2315
    did         integer,
 
2316
    date_prod   date,
 
2317
    kind        varchar(10),
 
2318
    len         interval hour to minute,
 
2319
    CONSTRAINT code_title PRIMARY KEY(code,title)
 
2320
);</PRE
 
2321
><P>
 
2322
  </P
 
2323
><P
 
2324
>   Define a primary key constraint for table
 
2325
   <TT
 
2326
CLASS="STRUCTNAME"
 
2327
>distributors</TT
 
2328
>.  The following two examples are
 
2329
   equivalent, the first using the table constraint syntax, the second
 
2330
   the column constraint syntax:
 
2331
 
 
2332
</P><PRE
 
2333
CLASS="PROGRAMLISTING"
 
2334
>CREATE TABLE distributors (
 
2335
    did     integer,
 
2336
    name    varchar(40),
 
2337
    PRIMARY KEY(did)
 
2338
);</PRE
 
2339
><P>
 
2340
 
 
2341
</P><PRE
 
2342
CLASS="PROGRAMLISTING"
 
2343
>CREATE TABLE distributors (
 
2344
    did     integer PRIMARY KEY,
 
2345
    name    varchar(40)
 
2346
);</PRE
 
2347
><P>
 
2348
  </P
 
2349
><P
 
2350
>   Assign a literal constant default value for the column
 
2351
   <TT
 
2352
CLASS="LITERAL"
 
2353
>name</TT
 
2354
>, arrange for the default value of column
 
2355
   <TT
 
2356
CLASS="LITERAL"
 
2357
>did</TT
 
2358
> to be generated by selecting the next value
 
2359
   of a sequence object, and make the default value of
 
2360
   <TT
 
2361
CLASS="LITERAL"
 
2362
>modtime</TT
 
2363
> be the time at which the row is
 
2364
   inserted:
 
2365
 
 
2366
</P><PRE
 
2367
CLASS="PROGRAMLISTING"
 
2368
>CREATE TABLE distributors (
 
2369
    name      varchar(40) DEFAULT 'Luso Films',
 
2370
    did       integer DEFAULT nextval('distributors_serial'),
 
2371
    modtime   timestamp DEFAULT current_timestamp
 
2372
);</PRE
 
2373
><P>
 
2374
  </P
 
2375
><P
 
2376
>   Define two <TT
 
2377
CLASS="LITERAL"
 
2378
>NOT NULL</TT
 
2379
> column constraints on the table
 
2380
   <CODE
 
2381
CLASS="CLASSNAME"
 
2382
>distributors</CODE
 
2383
>, one of which is explicitly
 
2384
   given a name:
 
2385
 
 
2386
</P><PRE
 
2387
CLASS="PROGRAMLISTING"
 
2388
>CREATE TABLE distributors (
 
2389
    did     integer CONSTRAINT no_null NOT NULL,
 
2390
    name    varchar(40) NOT NULL
 
2391
);</PRE
 
2392
><P>
 
2393
    </P
 
2394
><P
 
2395
>     Define a unique constraint for the <TT
 
2396
CLASS="LITERAL"
 
2397
>name</TT
 
2398
> column:
 
2399
 
 
2400
</P><PRE
 
2401
CLASS="PROGRAMLISTING"
 
2402
>CREATE TABLE distributors (
 
2403
    did     integer,
 
2404
    name    varchar(40) UNIQUE
 
2405
);</PRE
 
2406
><P>
 
2407
 
 
2408
     The same, specified as a table constraint:
 
2409
 
 
2410
</P><PRE
 
2411
CLASS="PROGRAMLISTING"
 
2412
>CREATE TABLE distributors (
 
2413
    did     integer,
 
2414
    name    varchar(40),
 
2415
    UNIQUE(name)
 
2416
);</PRE
 
2417
><P>
 
2418
  </P
 
2419
><P
 
2420
>   Create the same table, specifying 70% fill factor for both the table
 
2421
   and its unique index:
 
2422
 
 
2423
</P><PRE
 
2424
CLASS="PROGRAMLISTING"
 
2425
>CREATE TABLE distributors (
 
2426
    did     integer,
 
2427
    name    varchar(40),
 
2428
    UNIQUE(name) WITH (fillfactor=70)
 
2429
)
 
2430
WITH (fillfactor=70);</PRE
 
2431
><P>
 
2432
  </P
 
2433
><P
 
2434
>   Create table <TT
 
2435
CLASS="STRUCTNAME"
 
2436
>circles</TT
 
2437
> with an exclusion
 
2438
   constraint that prevents any two circles from overlapping:
 
2439
 
 
2440
</P><PRE
 
2441
CLASS="PROGRAMLISTING"
 
2442
>CREATE TABLE circles (
 
2443
    c circle,
 
2444
    EXCLUDE USING gist (c WITH &amp;&amp;)
 
2445
);</PRE
 
2446
><P>
 
2447
  </P
 
2448
><P
 
2449
>   Create table <TT
 
2450
CLASS="STRUCTNAME"
 
2451
>cinemas</TT
 
2452
> in tablespace <TT
 
2453
CLASS="STRUCTNAME"
 
2454
>diskvol1</TT
 
2455
>:
 
2456
 
 
2457
</P><PRE
 
2458
CLASS="PROGRAMLISTING"
 
2459
>CREATE TABLE cinemas (
 
2460
        id serial,
 
2461
        name text,
 
2462
        location text
 
2463
) TABLESPACE diskvol1;</PRE
 
2464
><P>
 
2465
  </P
 
2466
><P
 
2467
>   Create a composite type and a typed table:
 
2468
</P><PRE
 
2469
CLASS="PROGRAMLISTING"
 
2470
>CREATE TYPE employee_type AS (name text, salary numeric);
 
2471
 
 
2472
CREATE TABLE employees OF employee_type (
 
2473
    PRIMARY KEY (name),
 
2474
    salary WITH OPTIONS DEFAULT 1000
 
2475
);</PRE
 
2476
><P>
 
2477
  </P
 
2478
></DIV
 
2479
><DIV
 
2480
CLASS="REFSECT1"
 
2481
><A
 
2482
NAME="SQL-CREATETABLE-COMPATIBILITY"
 
2483
></A
 
2484
><H2
 
2485
>Compatibility</H2
 
2486
><P
 
2487
>   The <TT
 
2488
CLASS="COMMAND"
 
2489
>CREATE TABLE</TT
 
2490
> command conforms to the
 
2491
   <ACRONYM
 
2492
CLASS="ACRONYM"
 
2493
>SQL</ACRONYM
 
2494
> standard, with exceptions listed below.
 
2495
  </P
 
2496
><DIV
 
2497
CLASS="REFSECT2"
 
2498
><A
 
2499
NAME="AEN67812"
 
2500
></A
 
2501
><H3
 
2502
>Temporary Tables</H3
 
2503
><P
 
2504
>    Although the syntax of <TT
 
2505
CLASS="LITERAL"
 
2506
>CREATE TEMPORARY TABLE</TT
 
2507
>
 
2508
    resembles that of the SQL standard, the effect is not the same.  In the
 
2509
    standard,
 
2510
    temporary tables are defined just once and automatically exist (starting
 
2511
    with empty contents) in every session that needs them.
 
2512
    <SPAN
 
2513
CLASS="PRODUCTNAME"
 
2514
>PostgreSQL</SPAN
 
2515
> instead
 
2516
    requires each session to issue its own <TT
 
2517
CLASS="LITERAL"
 
2518
>CREATE TEMPORARY
 
2519
    TABLE</TT
 
2520
> command for each temporary table to be used.  This allows
 
2521
    different sessions to use the same temporary table name for different
 
2522
    purposes, whereas the standard's approach constrains all instances of a
 
2523
    given temporary table name to have the same table structure.
 
2524
   </P
 
2525
><P
 
2526
>    The standard's definition of the behavior of temporary tables is
 
2527
    widely ignored.  <SPAN
 
2528
CLASS="PRODUCTNAME"
 
2529
>PostgreSQL</SPAN
 
2530
>'s behavior
 
2531
    on this point is similar to that of several other SQL databases.
 
2532
   </P
 
2533
><P
 
2534
>    The standard's distinction between global and local temporary tables
 
2535
    is not in <SPAN
 
2536
CLASS="PRODUCTNAME"
 
2537
>PostgreSQL</SPAN
 
2538
>, since that distinction
 
2539
    depends on the concept of modules, which
 
2540
    <SPAN
 
2541
CLASS="PRODUCTNAME"
 
2542
>PostgreSQL</SPAN
 
2543
> does not have.
 
2544
    For compatibility's sake, <SPAN
 
2545
CLASS="PRODUCTNAME"
 
2546
>PostgreSQL</SPAN
 
2547
> will
 
2548
    accept the <TT
 
2549
CLASS="LITERAL"
 
2550
>GLOBAL</TT
 
2551
> and <TT
 
2552
CLASS="LITERAL"
 
2553
>LOCAL</TT
 
2554
> keywords
 
2555
    in a temporary table declaration, but they have no effect.
 
2556
   </P
 
2557
><P
 
2558
>    The <TT
 
2559
CLASS="LITERAL"
 
2560
>ON COMMIT</TT
 
2561
> clause for temporary tables
 
2562
    also resembles the SQL standard, but has some differences.
 
2563
    If the <TT
 
2564
CLASS="LITERAL"
 
2565
>ON COMMIT</TT
 
2566
> clause is omitted, SQL specifies that the
 
2567
    default behavior is <TT
 
2568
CLASS="LITERAL"
 
2569
>ON COMMIT DELETE ROWS</TT
 
2570
>.  However, the
 
2571
    default behavior in <SPAN
 
2572
CLASS="PRODUCTNAME"
 
2573
>PostgreSQL</SPAN
 
2574
> is
 
2575
    <TT
 
2576
CLASS="LITERAL"
 
2577
>ON COMMIT PRESERVE ROWS</TT
 
2578
>.  The <TT
 
2579
CLASS="LITERAL"
 
2580
>ON COMMIT
 
2581
    DROP</TT
 
2582
> option does not exist in SQL.
 
2583
   </P
 
2584
></DIV
 
2585
><DIV
 
2586
CLASS="REFSECT2"
 
2587
><A
 
2588
NAME="AEN67833"
 
2589
></A
 
2590
><H3
 
2591
>Non-deferred Uniqueness Constraints</H3
 
2592
><P
 
2593
>    When a <TT
 
2594
CLASS="LITERAL"
 
2595
>UNIQUE</TT
 
2596
> or <TT
 
2597
CLASS="LITERAL"
 
2598
>PRIMARY KEY</TT
 
2599
> constraint is
 
2600
    not deferrable, <SPAN
 
2601
CLASS="PRODUCTNAME"
 
2602
>PostgreSQL</SPAN
 
2603
> checks for
 
2604
    uniqueness immediately whenever a row is inserted or modified.
 
2605
    The SQL standard says that uniqueness should be enforced only at
 
2606
    the end of the statement; this makes a difference when, for example,
 
2607
    a single command updates multiple key values.  To obtain
 
2608
    standard-compliant behavior, declare the constraint as
 
2609
    <TT
 
2610
CLASS="LITERAL"
 
2611
>DEFERRABLE</TT
 
2612
> but not deferred (i.e., <TT
 
2613
CLASS="LITERAL"
 
2614
>INITIALLY
 
2615
    IMMEDIATE</TT
 
2616
>).  Be aware that this can be significantly slower than
 
2617
    immediate uniqueness checking.
 
2618
   </P
 
2619
></DIV
 
2620
><DIV
 
2621
CLASS="REFSECT2"
 
2622
><A
 
2623
NAME="AEN67841"
 
2624
></A
 
2625
><H3
 
2626
>Column Check Constraints</H3
 
2627
><P
 
2628
>    The SQL standard says that <TT
 
2629
CLASS="LITERAL"
 
2630
>CHECK</TT
 
2631
> column constraints
 
2632
    can only refer to the column they apply to; only <TT
 
2633
CLASS="LITERAL"
 
2634
>CHECK</TT
 
2635
>
 
2636
    table constraints can refer to multiple columns.
 
2637
    <SPAN
 
2638
CLASS="PRODUCTNAME"
 
2639
>PostgreSQL</SPAN
 
2640
> does not enforce this
 
2641
    restriction; it treats column and table check constraints alike.
 
2642
   </P
 
2643
></DIV
 
2644
><DIV
 
2645
CLASS="REFSECT2"
 
2646
><A
 
2647
NAME="AEN67847"
 
2648
></A
 
2649
><H3
 
2650
><TT
 
2651
CLASS="LITERAL"
 
2652
>EXCLUDE</TT
 
2653
> Constraint</H3
 
2654
><P
 
2655
>    The <TT
 
2656
CLASS="LITERAL"
 
2657
>EXCLUDE</TT
 
2658
> constraint type is a
 
2659
    <SPAN
 
2660
CLASS="PRODUCTNAME"
 
2661
>PostgreSQL</SPAN
 
2662
> extension.
 
2663
   </P
 
2664
></DIV
 
2665
><DIV
 
2666
CLASS="REFSECT2"
 
2667
><A
 
2668
NAME="AEN67853"
 
2669
></A
 
2670
><H3
 
2671
><TT
 
2672
CLASS="LITERAL"
 
2673
>NULL</TT
 
2674
> <SPAN
 
2675
CLASS="QUOTE"
 
2676
>"Constraint"</SPAN
 
2677
></H3
 
2678
><P
 
2679
>    The <TT
 
2680
CLASS="LITERAL"
 
2681
>NULL</TT
 
2682
> <SPAN
 
2683
CLASS="QUOTE"
 
2684
>"constraint"</SPAN
 
2685
> (actually a
 
2686
    non-constraint) is a <SPAN
 
2687
CLASS="PRODUCTNAME"
 
2688
>PostgreSQL</SPAN
 
2689
>
 
2690
    extension to the SQL standard that is included for compatibility with some
 
2691
    other database systems (and for symmetry with the <TT
 
2692
CLASS="LITERAL"
 
2693
>NOT
 
2694
    NULL</TT
 
2695
> constraint).  Since it is the default for any
 
2696
    column, its presence is simply noise.
 
2697
   </P
 
2698
></DIV
 
2699
><DIV
 
2700
CLASS="REFSECT2"
 
2701
><A
 
2702
NAME="AEN67862"
 
2703
></A
 
2704
><H3
 
2705
>Inheritance</H3
 
2706
><P
 
2707
>    Multiple inheritance via the <TT
 
2708
CLASS="LITERAL"
 
2709
>INHERITS</TT
 
2710
> clause is
 
2711
    a <SPAN
 
2712
CLASS="PRODUCTNAME"
 
2713
>PostgreSQL</SPAN
 
2714
> language extension.
 
2715
    SQL:1999 and later define single inheritance using a
 
2716
    different syntax and different semantics.  SQL:1999-style
 
2717
    inheritance is not yet supported by
 
2718
    <SPAN
 
2719
CLASS="PRODUCTNAME"
 
2720
>PostgreSQL</SPAN
 
2721
>.
 
2722
   </P
 
2723
></DIV
 
2724
><DIV
 
2725
CLASS="REFSECT2"
 
2726
><A
 
2727
NAME="AEN67868"
 
2728
></A
 
2729
><H3
 
2730
>Zero-column Tables</H3
 
2731
><P
 
2732
>    <SPAN
 
2733
CLASS="PRODUCTNAME"
 
2734
>PostgreSQL</SPAN
 
2735
> allows a table of no columns
 
2736
    to be created (for example, <TT
 
2737
CLASS="LITERAL"
 
2738
>CREATE TABLE foo();</TT
 
2739
>).  This
 
2740
    is an extension from the SQL standard, which does not allow zero-column
 
2741
    tables.  Zero-column tables are not in themselves very useful, but
 
2742
    disallowing them creates odd special cases for <TT
 
2743
CLASS="COMMAND"
 
2744
>ALTER TABLE
 
2745
    DROP COLUMN</TT
 
2746
>, so it seems cleaner to ignore this spec restriction.
 
2747
   </P
 
2748
></DIV
 
2749
><DIV
 
2750
CLASS="REFSECT2"
 
2751
><A
 
2752
NAME="AEN67874"
 
2753
></A
 
2754
><H3
 
2755
><TT
 
2756
CLASS="LITERAL"
 
2757
>WITH</TT
 
2758
> Clause</H3
 
2759
><P
 
2760
>    The <TT
 
2761
CLASS="LITERAL"
 
2762
>WITH</TT
 
2763
> clause is a <SPAN
 
2764
CLASS="PRODUCTNAME"
 
2765
>PostgreSQL</SPAN
 
2766
>
 
2767
    extension; neither storage parameters nor OIDs are in the standard.
 
2768
   </P
 
2769
></DIV
 
2770
><DIV
 
2771
CLASS="REFSECT2"
 
2772
><A
 
2773
NAME="AEN67880"
 
2774
></A
 
2775
><H3
 
2776
>Tablespaces</H3
 
2777
><P
 
2778
>    The <SPAN
 
2779
CLASS="PRODUCTNAME"
 
2780
>PostgreSQL</SPAN
 
2781
> concept of tablespaces is not
 
2782
    part of the standard.  Hence, the clauses <TT
 
2783
CLASS="LITERAL"
 
2784
>TABLESPACE</TT
 
2785
>
 
2786
    and <TT
 
2787
CLASS="LITERAL"
 
2788
>USING INDEX TABLESPACE</TT
 
2789
> are extensions.
 
2790
   </P
 
2791
></DIV
 
2792
><DIV
 
2793
CLASS="REFSECT2"
 
2794
><A
 
2795
NAME="AEN67886"
 
2796
></A
 
2797
><H3
 
2798
>Typed Tables</H3
 
2799
><P
 
2800
>    Typed tables implement a subset of the SQL standard.  According to
 
2801
    the standard, a typed table has columns corresponding to the
 
2802
    underlying composite type as well as one other column that is
 
2803
    the <SPAN
 
2804
CLASS="QUOTE"
 
2805
>"self-referencing column"</SPAN
 
2806
>.  PostgreSQL does not
 
2807
    support these self-referencing columns explicitly, but the same
 
2808
    effect can be had using the OID feature.
 
2809
   </P
 
2810
></DIV
 
2811
></DIV
 
2812
><DIV
 
2813
CLASS="REFSECT1"
 
2814
><A
 
2815
NAME="AEN67890"
 
2816
></A
 
2817
><H2
 
2818
>See Also</H2
 
2819
><A
 
2820
HREF="sql-altertable.html"
 
2821
>ALTER TABLE</A
 
2822
>, <A
 
2823
HREF="sql-droptable.html"
 
2824
>DROP TABLE</A
 
2825
>, <A
 
2826
HREF="sql-createtablespace.html"
 
2827
>CREATE TABLESPACE</A
 
2828
>, <A
 
2829
HREF="sql-createtype.html"
 
2830
>CREATE TYPE</A
 
2831
></DIV
 
2832
><DIV
 
2833
CLASS="NAVFOOTER"
 
2834
><HR
 
2835
ALIGN="LEFT"
 
2836
WIDTH="100%"><TABLE
 
2837
SUMMARY="Footer navigation table"
 
2838
WIDTH="100%"
 
2839
BORDER="0"
 
2840
CELLPADDING="0"
 
2841
CELLSPACING="0"
 
2842
><TR
 
2843
><TD
 
2844
WIDTH="33%"
 
2845
ALIGN="left"
 
2846
VALIGN="top"
 
2847
><A
 
2848
HREF="sql-createserver.html"
 
2849
ACCESSKEY="P"
 
2850
>Prev</A
 
2851
></TD
 
2852
><TD
 
2853
WIDTH="34%"
 
2854
ALIGN="center"
 
2855
VALIGN="top"
 
2856
><A
 
2857
HREF="index.html"
 
2858
ACCESSKEY="H"
 
2859
>Home</A
 
2860
></TD
 
2861
><TD
 
2862
WIDTH="33%"
 
2863
ALIGN="right"
 
2864
VALIGN="top"
 
2865
><A
 
2866
HREF="sql-createtableas.html"
 
2867
ACCESSKEY="N"
 
2868
>Next</A
 
2869
></TD
 
2870
></TR
 
2871
><TR
 
2872
><TD
 
2873
WIDTH="33%"
 
2874
ALIGN="left"
 
2875
VALIGN="top"
 
2876
>CREATE SERVER</TD
 
2877
><TD
 
2878
WIDTH="34%"
 
2879
ALIGN="center"
 
2880
VALIGN="top"
 
2881
><A
 
2882
HREF="sql-commands.html"
 
2883
ACCESSKEY="U"
 
2884
>Up</A
 
2885
></TD
 
2886
><TD
 
2887
WIDTH="33%"
 
2888
ALIGN="right"
 
2889
VALIGN="top"
 
2890
>CREATE TABLE AS</TD
 
2891
></TR
 
2892
></TABLE
 
2893
></DIV
 
2894
></BODY
 
2895
></HTML
 
2896
>
 
 
b'\\ No newline at end of file'