Create New Table by Selecting Data from Other Tables with CREATE TABLE AS创建新的表选取的数据来自其他表,创建表

By using SQL data manipulation statement, a new, temporary, backup or regular table can be created and filled or inserted with data from another table or tables retrieved by SELECT statement.使用SQL数据操作声明中,一个新的,暂时的,备份或定期表可以创建和填充或插入数据从另一个表或表格检索SELECT语句。 The SQL data manipulation language is CREATE TABLE AS which can be used to create a new table built from contents of result set by a query on a table that already exists within the database.在SQL数据操纵语言是建立表,可用于创建一个新表从内容建设的结果集的查询表上已经存在的数据库。 Both the column types, and row data for the new table, come from the SELECT command specified by select.这两种类型的列,并连续数据的新表中,来自选择的命令所指明的选择。

CREATE TABLE AS has the following syntax or synopsis in simple form:创建表具有下列语法或大纲在简单的形式:

CREATE TABLE new_table_name [ ( column [, ...] ) ] AS SELECT [ ( column [, ...] ) ] FROM existing table_name创建表new_table_name [ (栏[ , ... ] ) ]精选[ (栏[ , ... ] ) ] 现有table_name

The SELECT statement can be in a complex form where data is been retrieved from several tables. SELECT语句可以是一个复杂的形式下得到的数据是从几个检索表。 For the new table, column names can be specified by including the column names in a comma-delimited list.对于新的表,列的名称可以被指定的包括列名在一个逗号分隔的列表。 Very important point to take note is that there should be the same number of columns specified in the column list preceding the AS clause (optional, if specified) for new table as the number of target columns that are returned by the select statement.很重要的一点注意的是,应该有相同数目的列中指定的列清单作为前条第(可选,如果指定的话)的新表的人数指标列返回的选择发言。 If the optional list of columns in parentheses of new table contains different number of rows than the rows the SELECT statement returns, the following error message will be displayed:如果可选的清单栏括号中的新表中包含不同的行数比列的SELECT语句返回,下面的错误信息会显示:

ERROR: CREATE TABLE/AS SELECT has mismatched column count错误:创建表/精选了不匹配的列计数

In its simplest form, CREATE TABLE AS statement will create a complete backup of an existing table including all columns and data simply by using the statement CREATE TABLE new_table_name AS SELECT * FROM existing_table_name .最简单的形式,创建表的声明将建立一个完整的数据备份现有的表包括所有数据列和使用简单的声明创建表new_table_name选定*从existing_table_name

IMPORTANT : This is a machine translated page which is provided "as is" without warranty. 重要说明:这是一台机器翻译网页这是“原样”提供,无保修。 Machine translation may be difficult to understand.机器翻译可能很难理解。 Please refer to请参阅 original English article英文原文的文章 whenever possible.只要有可能。

Share and contribute or get technical support and help at共享和贡献或获得技术支持和帮助 My Digital Life Forums 我的数字生活论坛 .



2 Responses to “Create New Table by Selecting Data from Other Tables with CREATE TABLE AS”第2响应“创建新表由选择的数据与其他表创建表的”

  1. ikarus
    April 1st, 2007 03:26 2007年4月1号3点26分
    1

    We can do it also with the query,我们可以做到这一点也与查询,

    SELECT * INTO newtable FROM existingtable选择*导入newtable从existingtable

    I think its a little bit shorter.我认为它有点短。

  2. tariq塔里克
    January 10th, 2008 13:31 2008年1月10号13:31
    2

    Data in the table that is created using create table as select” is different from the data that is returned when the same select that creates the table is executed separately????数据表中创建使用创建表,选择“是不同的数据,返回时同样的选择,创造的表单独执行? ? ? ?
    WE are using the tool PL/SQL Developer .我们正在使用的工具特等/数据库开发人员。
    Any idea what this problem is due to?任何知道这个问题是因为?

Leave a Reply留下一个回复

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> 您可以使用这些标签: href="" title="">的<a <abbr title=""> <acronym title="">的<b> <blockquote cite=""> <cite>的<code> “删除日期时间= “ ” “的<em> <i> <q cite=""> <strike>的<strong>

Subscribe without commenting订阅没有评论


Custom Search

New Articles新文章

Incoming Search Terms for the Article收到的搜索字词的文章

create table as select 创建表的选择 - - create table select 创建表选择 - - create table from select 创建表选择 - - db2 create table as select 创建的DB2表选择 - - create new table 创建新的表 - - DB2 create table select 创建的DB2表选择 - - create table with select 创建表与选择 - - create table select from 创建表选择 - - create table as select oracle 创建表的选择甲骨文 - - create table as select db2 创建表作为选择的DB2 - - create table as select 创建表的选择 - - db2 create table from select 创建表的DB2从选择 - - create table as select from 创建表的选择 - - new table myspace MySpace的新表 - - select create table 选择创建表 - - create table using select 创建表使用选择 - - oracle select into new table 甲骨文公司选择到新的表 - - oracle create table select 甲骨文公司创建表选择 - - add a table to myspace 新增一个表格供应 - - oracle create table as select 甲骨文公司创建表选择 - - access create table select 进入创建表选择 - - db2 create table from another table 创建表的DB2从另一个表 - - create table as select in db2 创建表中选取的DB2 - - db2 create table WITH DATA 创建的DB2数据表 - - create backup table sql 建立备份表的SQL - - create table with data 创建数据表 - - access create table as select 进入创建表选择 - - create table select access 创建表选择机会 - - create table by select 创建表的选择 - - create table from another table ms access 创建表从另一个表毫秒访问 - - myspace new table MySpace的新表 - - create table + select 创建表+选择 - - sql create backup table 数据库建立备份表 - - create a new table 创建一个新表 - - create new table from select 创建新的表选取 - - db2 create table 创建的DB2表 - - DB2 create table as 创建的DB2表 - - myspace create table MySpace的创建表 - - create table select * from 创建表的选择* - - myspace add new table 供应增加新的表 - - create table select 创建表选择 - - create table select db2 创建表选择的DB2 - - create table select oracle 创建表选择甲骨文 - - access create table as 访问表的创建 - - ms access create table as select 创建毫秒访问表选择 - - create table as select 创建表的选择 - - create backup table in oracle 建立备份表在Oracle - - create table in DB2 创建表中的DB2 - - create new table on myspace 创建新的表在MySpace - - create table select * from 创建表的选择* - -