select_into.7
来自「PostgreSQL 8.2中增加了很多企业用户所需要的功能和性能上的提高,其开」· 7 代码 · 共 80 行
7
80 行
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "SELECT INTO" "" "2008-01-03" "SQL - Language Statements" "SQL Commands".SH NAMESELECT INTO \- define a new table from the results of a query.SH SYNOPSIS.sp.nfSELECT [ ALL | DISTINCT [ ON ( \fIexpression\fR [, ...] ) ] ] * | \fIexpression\fR [ AS \fIoutput_name\fR ] [, ...] INTO [ TEMPORARY | TEMP ] [ TABLE ] \fInew_table\fR [ FROM \fIfrom_item\fR [, ...] ] [ WHERE \fIcondition\fR ] [ GROUP BY \fIexpression\fR [, ...] ] [ HAVING \fIcondition\fR [, ...] ] [ { UNION | INTERSECT | EXCEPT } [ ALL ] \fIselect\fR ] [ ORDER BY \fIexpression\fR [ ASC | DESC | USING \fIoperator\fR ] [, ...] ] [ LIMIT { \fIcount\fR | ALL } ] [ OFFSET \fIstart\fR ] [ FOR { UPDATE | SHARE } [ OF \fItable_name\fR [, ...] ] [ NOWAIT ] [...] ].sp.fi.SH "DESCRIPTION".PP\fBSELECT INTO\fR creates a new table and fills itwith data computed by a query. The data is not returned to theclient, as it is with a normal \fBSELECT\fR. The newtable's columns have the names and data types associated with theoutput columns of the \fBSELECT\fR..SH "PARAMETERS".TP\fBTEMPORARY or TEMP\fRIf specified, the table is created as a temporary table. Referto CREATE TABLE [\fBcreate_table\fR(7)] for details..TP\fB\fInew_table\fB\fRThe name (optionally schema-qualified) of the table to be created..PPAll other parameters are described in detail under SELECT [\fBselect\fR(7)]..PP.SH "NOTES".PPCREATE TABLE AS [\fBcreate_table_as\fR(7)] is functionally similar to\fBSELECT INTO\fR. \fBCREATE TABLE AS\fRis the recommended syntax, since this form of \fBSELECTINTO\fR is not available in \fBECPG\fRor \fBPL/pgSQL\fR, because they interpret theINTO clause differently. Furthermore,\fBCREATE TABLE AS\fR offers a superset of thefunctionality provided by \fBSELECT INTO\fR..PPPrior to PostgreSQL 8.1, the table created by\fBSELECT INTO\fR included OIDs by default. InPostgreSQL 8.1, this is not the case\(em to include OIDs in the new table, the default_with_oids configuration variable must beenabled. Alternatively, \fBCREATE TABLE AS\fR can beused with the WITH OIDS clause..SH "EXAMPLES".PPCreate a new table films_recent consisting of onlyrecent entries from the table films:.sp.nfSELECT * INTO films_recent FROM films WHERE date_prod >= '2002-01-01';.sp.fi.SH "COMPATIBILITY".PPThe SQL standard uses \fBSELECT INTO\fR torepresent selecting values into scalar variables of a host program,rather than creating a new table. This indeed is the usage foundin \fBECPG\fR (see in the documentation) and\fBPL/pgSQL\fR (see in the documentation).The PostgreSQL usage of \fBSELECTINTO\fR to represent table creation is historical. It isbest to use \fBCREATE TABLE AS\fR for this purpose innew code..SH "SEE ALSO"CREATE TABLE AS [\fBcreate_table_as\fR(7)]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?