SELECT INTO 中文man页面

系统
SELECT INTO 从一个查询的计算结果中创建一个新表。 数据并不返回给客户端,这一点和普通的 SELECT 不同。 新表的字段具有和 SELECT 的输出字段相关联(相同)的名字和数据类型。

NAME

SELECT INTO - 从一个查询的结果中创建一个新表

SYNOPSIS

SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
    * | expression [ AS output_name ] [, ...]
    INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table
    [ FROM from_item [, ...] ]
    [ WHERE condition ]
    [ GROUP BY expression [, ...] ]
    [ HAVING condition [, ...] ]
    [ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]
    [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
    [ LIMIT { count | ALL } ]
    [ OFFSET start ]
    [ FOR UPDATE [ OF tablename [, ...] ] ]

DESCRIPTION 描述

SELECT INTO 从一个查询的计算结果中创建一个新表。 数据并不返回给客户端,这一点和普通的 SELECT 不同。 新表的字段具有和 SELECT 的输出字段相关联(相同)的名字和数据类型。  

PARAMETERS 参数

TEMPORARY 或 TEMP

 如果声明了这个关键字,那么该表是作为一个临时表创建的。 请参考 CREATE TABLE [create_table(7)] 获取细节。
new_table

 要创建的表的表名(可以有模式修饰)。


 所有其它输入的域都在 SELECT [select(7)] 中有详细描述。

NOTES 注意

CREATE TABLE AS [create_table_as(7)] 的作用和 SELECT INTO 相同。 我们建议使用 CREATE TABLE AS 语法, 因为 SELECT INTO 不是标准语法。 实际上,这种类型的 SELECT INTO 是不能在 ECPG 或者 PL/pgSQL 中使用的, 因为它们对 INTO 子句的解释是不同的。  

COMPATIBILITY 兼容性


 SQL 标准用 SELECT ... INTO 表示选取数值到一个宿主程序的标量变量中, 而不是创建一个新表。这种用法实际上就是在 ECPG  (参阅 Chapter 29)和PL/pgSQL  (Chapter 35)里的用途。 PostgreSQL 用 SELECT INTO 代表创建表的意思是历史原因。 在新代码里我们***使用 CREATE TABLE AS 实现这个目地。 (CREATE TABLE AS 也不是标准,但至少它出现混淆的机会少一些。)  

#p#

NAME

SELECT INTO - create a new table from the results of a query

SYNOPSIS

SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
    * | expression [ AS output_name ] [, ...]
    INTO [ TEMPORARY | TEMP ] [ TABLE ] new_table
    [ FROM from_item [, ...] ]
    [ WHERE condition ]
    [ GROUP BY expression [, ...] ]
    [ HAVING condition [, ...] ]
    [ { UNION | INTERSECT | EXCEPT } [ ALL ] select ]
    [ ORDER BY expression [ ASC | DESC | USING operator ] [, ...] ]
    [ LIMIT { count | ALL } ]
    [ OFFSET start ]
    [ FOR UPDATE [ OF tablename [, ...] ] ]

DESCRIPTION

SELECT INTO creates a new table and fills it with data computed by a query. The data is not returned to the client, as it is with a normal SELECT. The new table's columns have the names and data types associated with the output columns of the SELECT.  

PARAMETERS

TEMPORARY or TEMP
If specified, the table is created as a temporary table. Refer to CREATE TABLE [create_table(7)] for details.
new_table
The name (optionally schema-qualified) of the table to be created.

All other parameters are described in detail under SELECT [select(7)].

NOTES

CREATE TABLE AS [create_table_as(7)] is functionally equivalent to SELECT INTO. CREATE TABLE AS is the recommended syntax, since this form of SELECT INTO is not available in ECPG or PL/pgSQL, because they interpret the INTO clause differently.  

COMPATIBILITY

The SQL standard uses SELECT ... INTO to represent selecting values into scalar variables of a host program, rather than creating a new table. This indeed is the usage found in ECPG and PL/pgSQL. The PostgreSQL usage of SELECT INTO to represent table creation is historical. It's best to use CREATE TABLE AS for this purpose in new code. (CREATE TABLE AS isn't standard either, but it's less likely to cause confusion.)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 17:42:52

SELECT中文man

2011-08-15 10:21:09

man中文man

2011-08-24 16:48:36

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-12 14:58:05

killall中文man

2011-07-15 16:58:36

ac中文man

2011-08-15 11:10:48

more中文man

2011-08-25 17:03:51

pclose中文man

2011-08-15 14:10:37

tar中文man

2011-08-16 10:42:30

rmmod中文man

2011-08-11 17:46:02

chmod中文man

2011-08-18 13:57:38

acct中文man

2011-08-23 17:49:36

zdump中文man

2011-08-15 15:10:49

wall中文man

2011-08-23 15:06:03

quotastats中文man

2011-08-15 17:35:50

ar中文man

2011-08-25 09:07:16

suffixes中文man

2011-08-25 17:53:26

stdio中文man

2011-08-18 15:21:37

autofs中文man
点赞
收藏

51CTO技术栈公众号