Imported upstream version 1.5
[manpages-zh.git] / raw / man7 / create_table_as.7
blob0e045fba7cdbf652abd06f00084ca0e12a1974ba
1 .\\" auto-generated by docbook2man-spec $Revision: 1.1 $
2 .TH "CREATE TABLE AS" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands"
3 .SH NAME
4 CREATE TABLE AS \- create a new table from the results of a query
6 .SH SYNOPSIS
7 .sp
8 .nf
9 CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE \fItable_name\fR [ (\fIcolumn_name\fR [, ...] ) ]
10     AS \fIquery\fR
11 .sp
12 .fi
13 .SH "DESCRIPTION"
14 .PP
15 \fBCREATE TABLE AS\fR creates a table and fills it
16 with data computed by a \fBSELECT\fR command or an
17 \fBEXECUTE\fR that runs a prepared
18 \fBSELECT\fR command. The table columns have the
19 names and data types associated with the output columns of the
20 \fBSELECT\fR (except that you can override the column
21 names by giving an explicit list of new column names).
22 .PP
23 \fBCREATE TABLE AS\fR bears some resemblance to
24 creating a view, but it is really quite different: it creates a new
25 table and evaluates the query just once to fill the new table
26 initially. The new table will not track subsequent changes to the
27 source tables of the query. In contrast, a view re-evaluates its
28 defining \fBSELECT\fR statement whenever it is
29 queried.
30 .SH "PARAMETERS"
31 .TP
32 \fBTEMPORARY or TEMP\fR
33 If specified, the table is created as a temporary table.
34 Refer to CREATE TABLE [\fBcreate_table\fR(7)] for details.
35 .TP
36 \fB\fItable_name\fB\fR
37 The name (optionally schema-qualified) of the table to be created.
38 .TP
39 \fB\fIcolumn_name\fB\fR
40 The name of a column in the new table. If column names are not
41 provided, they are taken from the output column names of the
42 query. If the table is created out of an
43 \fBEXECUTE\fR command, a column name list can
44 currently not be specified.
45 .TP
46 \fB\fIquery\fB\fR
47 A query statement (that is, a \fBSELECT\fR command
48 or an \fBEXECUTE\fR command that runs a prepared
49 \fBSELECT\fR command). Refer to SELECT [\fBselect\fR(7)] or EXECUTE [\fBexecute\fR(l)],
50 respectively, for a description of the allowed syntax.
51 .SH "NOTES"
52 .PP
53 This command is functionally equivalent to SELECT INTO [\fBselect_into\fR(7)], but it is preferred since it is less
54 likely to be confused with other uses of the \fBSELECT
55 \&... INTO\fR syntax.
56 .SH "COMPATIBILITY"
57 .PP
58 This command is modeled after an Oracle
59 feature. There is no command with equivalent functionality in
60 the SQL standard. However, a combination of CREATE
61 TABLE and INSERT ... SELECT can
62 accomplish the same thing with little more effort.
63 .SH "SEE ALSO"
64 CREATE TABLE [\fBcreate_table\fR(7)], CREATE VIEW [\fBcreate_view\fR(l)], EXECUTE [\fBexecute\fR(l)], SELECT [\fBselect\fR(l)], SELECT INTO [\fBselect_into\fR(l)]