CREATE TABLE AS 中文man页面

系统
CREATE TABLE AS 创建一个表并且用来自 SELECT 命令计算出来的数据填充该表。 该表的字段和 SELECT 输出字段的名字及类型相关。 (只不过你可以通过明确地给出一个字段名字列表来覆盖 SELECT 的字段名)。

NAME

CREATE TABLE AS - 从一条查询的结果中创建一个新表

SYNOPSIS

CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name [ (column_name [, ...] ) ]
    AS query

DESCRIPTION 描述

CREATE TABLE AS 创建一个表并且用来自 SELECT 命令计算出来的数据填充该表。 该表的字段和 SELECT 输出字段的名字及类型相关。 (只不过你可以通过明确地给出一个字段名字列表来覆盖 SELECT 的字段名)。

CREATE TABLE AS 和创建视图有点象, 不过两者之间实在是有比较大差异:它创建一个新表并且只对 SELECT 计算一次来填充这个新表。 新表不能跟踪 SELECT 的源表随后做的变化。 相比之下,每次做查询的时候,视图都重新计算定义它的 SELECT 语句。  

PARAMETERS 参数

TEMPORARY or TEMP

 如果声明了这个选项,则该表作为临时表创建。 参阅 CREATE TABLE [create_table(7)] 获取细节。
table_name

 要创建的表名(可以是用模式修饰的)。
column_name

 字段的名称。如果没有提供字段名字,那么就从查询的输出字段名中获取。 如果表是一个 EXECUTE 命令创建的, 那么当前就不能声明字段名列表。
query

 一个查询语句(也就是一条 SELECT 命令或者一条运行准备好的 SELECT 命令的 EXECUTE 命令),请分别参考 SELECT [select(7)] 或者 EXECUTE [execute(l)] 获取可以使用的语法的描述。

NOTES 注意


 这条命令从功能上等效于 SELECT INTO [select_into(7)], 但是我们更建议你用这个命令,因为它不太可能和 SELECT ... INTO 语法的其它方面的使用混淆。  

COMPATIBILITY 兼容性


 这条命令是根据 Oracle 的一个特性制作的。 在 SQL 标准中没有功能相等的命令。不过, 把 CREATE TABLE 和 INSERT ... SELECT  组合起来可以通过略微多一些的工作完成同样的事情。  

SEE ALSO 参见

CREATE TABLE [create_table(7)], CREATE VIEW [create_view(l)], EXECUTE [execute(l)], SELECT [select(l)], SELECT INTO [select_into(l)]  

#p#

NAME

CREATE TABLE AS - create a new table from the results of a query

SYNOPSIS

CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name [ (column_name [, ...] ) ]
    AS query

DESCRIPTION

CREATE TABLE AS creates a table and fills it with data computed by a SELECT command or an EXECUTE that runs a prepared SELECT command. The table columns have the names and data types associated with the output columns of the SELECT (except that you can override the column names by giving an explicit list of new column names).

CREATE TABLE AS bears some resemblance to creating a view, but it is really quite different: it creates a new table and evaluates the query just once to fill the new table initially. The new table will not track subsequent changes to the source tables of the query. In contrast, a view re-evaluates its defining SELECT statement whenever it is queried.  

PARAMETERS

TEMPORARY or TEMP
If specified, the table is created as a temporary table. Refer to CREATE TABLE [create_table(7)] for details.
table_name
The name (optionally schema-qualified) of the table to be created.
column_name
The name of a column in the new table. If column names are not provided, they are taken from the output column names of the query. If the table is created out of an EXECUTE command, a column name list can currently not be specified.
query
A query statement (that is, a SELECT command or an EXECUTE command that runs a prepared SELECT command). Refer to SELECT [select(7)] or EXECUTE [execute(l)], respectively, for a description of the allowed syntax.

NOTES

This command is functionally equivalent to SELECT INTO [select_into(7)], but it is preferred since it is less likely to be confused with other uses of the SELECT ... INTO syntax.  

COMPATIBILITY

This command is modeled after an Oracle feature. There is no command with equivalent functionality in the SQL standard. However, a combination of CREATE TABLE and INSERT ... SELECT can accomplish the same thing with little more effort.  

SEE ALSO

CREATE TABLE [create_table(7)], CREATE VIEW [create_view(l)], EXECUTE [execute(l)], SELECT [select(l)], SELECT INTO [select_into(l)]

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

2011-08-24 13:29:20

CREATE TABL中文man

2011-08-24 10:56:32

CREATE CONV中文man

2011-08-24 13:46:39

CREATE VIEW中文man

2011-08-24 13:43:09

CREATE USER中文man

2011-08-24 10:46:36

CREATE AGGR中文man

2011-08-24 11:15:24

CREATE INDE中文man

2011-08-24 13:36:25

CREATE TRIG中文man

2011-08-24 13:26:19

CREATE SEQU中文man

2011-08-24 11:02:11

CREATE DOMA中文man

2011-08-24 11:05:36

CREATE FUNC中文man

2011-08-24 13:39:44

CREATE TYPE中文man

2011-08-24 13:23:10

CREATE SCHE中文man

2011-08-24 10:59:19

CREATE DATA中文man

2011-08-24 11:18:53

CREATE LANG中文man

2011-08-24 11:10:17

CREATE GROU中文man

2011-08-24 11:23:20

CREATE OPER中文man

2011-08-24 11:31:47

CREATE RULE中文man

2011-08-25 14:07:55

create_modu中文man

2011-08-24 11:26:46

CREATE OPER中文man

2011-08-24 10:53:20

CREATE CONS中文man
点赞
收藏

51CTO技术栈公众号