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.都柱的類型,和行數據為新表,來自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 .我們正在使用的工具, PL / SQL的開發。
    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> 您可以使用這些標籤:的<a href="" title=""> <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 new table 創建新表 - - create table from select 創建表,由專責 - - DB2 create table as select DB2的創建表作為選擇 - - make a new section on myspace 作出一項新條文,在MySpace - - create table select 創建表選擇 - - create table from select statement 創建表,由專責聲明 - - db2 create table as 創建的DB2表 - - create table with select 創建表與選擇 - - how to make a new section on myspace 如何使一項新條文,在MySpace - - oracle create table as select 甲骨文公司創建表作為選擇 - - create table as select 創建表作為選擇 - - create table as select access 創建表作為選擇進入 - - new section on myspace 新訂的第在MySpace - - Create table using select 創建表使用SELECT - - db2 create table select DB2的創建表選擇 - - create table from other tables 創建表從其他表 - - new table myspace 新表MySpace上 - - access create table as select 進入創建表作為選擇 - - access create table select 進入創建表選擇 - - create table with data 創建表的數據 - - create table as select db2 創建表作為選擇的DB2 - - create table select access 創建表選擇權限 - - DB2 create table from another table DB2的創建表從另一個表 - - create table select as 創建表,選擇 - - add new section on myspace 新增的第在MySpace - - db2 create table from select DB2的創建表,由專責 - - ORACLE CREATE TABLE SELECT * FROM 甲骨文公司創建表選擇*從 - - create table from select * 創建表,由專責* - - CREATE TABLE AS SELECT IN ACCESS 創建表作為選擇在Access - - create a table in myspace 創建一個表在MySpace上 - - create new myspace table 創造新的MySpace上表 - - create table select db2 創建表選擇的DB2 - - create table from other table 創建表從其他表 - - create new section 創造新的節 - - oracle create table from select 甲骨文公司創建表,由專責 - - access create table from select 進入創建表,由專責 - - myspace create new table MySpace上創建新表 - - create table from another table in db2 創建表從另一個表中的DB2 - - create new table from existing table in oracle 創建新表,從現有的資料表在Oracle - - add tables myspace 添加表MySpace上 - - all 全部 - - create table (select 創建表(請選擇 - - oracle create table select 甲骨文公司創建表選擇 - - db2 create table as select DB2的創建表作為選擇 - - make new section on myspace 作出新的節在MySpace - - create table from another table Db2 創建表從另一個表的DB2 - - create new table as 創建新表 - - create table using select 創建表使用SELECT - -