Create New Table by Selecting Data from Other Tables with CREATE TABLE AS Tạo Bảng do Chọn Dữ liệu từ Bàn khác với 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. Bằng cách sử dụng lệnh SQL thao tác dữ liệu, một, mới tạm thời, thường xuyên sao lưu hoặc bảng có thể được tạo ra và làm đầy hoặc chèn với dữ liệu từ một bảng hay bảng lấy được bằng lệnh 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. Các dữ liệu SQL thao tác ngôn ngữ là CREATE TABLE AS có thể được dùng để tạo ra một bảng mới được xây dựng từ nội dung của kết quả được thiết lập bởi một truy vấn trên một bảng đã tồn tại trong cơ sở dữ liệu. Both the column types, and row data for the new table, come from the SELECT command specified by select. Cả hai cột các loại, và dữ liệu hàng cho bảng mới, đến từ những lệnh SELECT chỉ định bởi chọn.

CREATE TABLE AS has the following syntax or synopsis in simple form: CREATE TABLE AS có cú pháp sau đây hoặc tóm tắt trong hình thức đơn giản:

CREATE TABLE new_table_name [ ( column [, ...] ) ] AS SELECT [ ( column [, ...] ) ] FROM existing table_name CREATE TABLE new_table_name [(cột [...])] AS SELECT [(cột [...])] TỪ hiện table_name

The SELECT statement can be in a complex form where data is been retrieved from several tables. Các lệnh SELECT có thể được ở một hình thức phức tạp, nơi dữ liệu được lấy từ một số bảng. For the new table, column names can be specified by including the column names in a comma-delimited list. Đối với bảng mới, tên cột có thể được xác định bằng cách bao gồm các tên cột trong một danh sách phân cách bằng dấu phẩy-. 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. Rất quan trọng điểm để lưu ý là không nên có cùng số cột được chỉ định trong danh sách cột ngay trước mệnh đề AS (tùy chọn, nếu được chỉ định) cho bảng mới như số các cột mục tiêu đó được trả lại bằng cách tuyên bố chọn. 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: Nếu danh sách tùy chọn của các cột trong ngoặc đơn của bảng mới chứa số khác nhau của các hàng hơn so với các hàng trở về lệnh SELECT, thông báo lỗi sau sẽ được hiển thị:

ERROR: CREATE TABLE/AS SELECT has mismatched column count ERROR: CREATE TABLE / AS SELECT đã không hạnh phúc đếm cột

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 . Trong hình thức đơn giản nhất, CREATE TABLE AS tuyên bố sẽ tạo ra một bản sao lưu hoàn toàn của một bảng hiện bao gồm tất cả các cột và dữ liệu chỉ đơn giản bằng cách sử dụng báo cáo TẠO new_table_name TABLE AS SELECT * FROM existing_table_name.

IMPORTANT : The page is machine translated and provided "as is" without warranty. Quan trọng: Sửa là máy dịch và cung cấp "như là" không có bảo hành. Machine translation may be difficult to understand. Máy dịch thuật có thể khó hiểu. Please refer to Vui lòng tham khảo original English article bản gốc tiếng Anh bài viết whenever possible. bất cứ khi nào có thể.


4 Responses to “Create New Table by Selecting Data from Other Tables with CREATE TABLE AS” 4 Responses to "Tạo Bảng do Chọn Dữ liệu từ Bàn khác với CREATE TABLE AS"

  1. Imran Aziz Khan Imran Aziz Khan
    September 5th, 2009 14:30 05 Tháng 9 2009 14:30
    4 4

    Check your select statement again and shuffle the joining conditions in where clause. Kiểm tra một lần nữa tuyên bố lựa chọn của bạn và shuffle các điều kiện tham gia tại nơi khoản. No need to change but change the position. Không cần phải thay đổi nhưng thay đổi vị trí. Try to equate id's first and contants latter. Hãy thử để đánh đồng id của contants thứ nhất và thứ hai. Hope this will solve your problem. Hy vọng điều này sẽ giải quyết vấn đề của bạn.

  2. Dinesh Dinesh
    January 28th, 2009 17:46 28 Tháng 1 2009 17:46
    3 3

    CREATE TABLE new_table_name [ ( column [, ...] ) ] AS SELECT [ ( column [, ...] ) ] FROM existing table_name CREATE TABLE new_table_name [(cột [...])] AS SELECT [(cột [...])] TỪ hiện table_name

    this query possible in MS-ACCESS or not truy vấn này có thể có trong MS-ACCESS hay không

  3. tariq Tariq
    January 10th, 2008 13:31 10 tháng một năm 2008 13:31
    2 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???? Dữ liệu trong bảng được tạo ra bằng cách sử dụng như là tạo ra bảng chọn "là khác nhau từ các dữ liệu được trả lại khi cùng chọn tạo bảng được thực thi một cách riêng biệt????
    WE are using the tool PL/SQL Developer . WE đang sử dụng công cụ PL / SQL Developer.
    Any idea what this problem is due to? Bất cứ ý tưởng gì vấn đề này là do?

  4. ikarus Ikarus
    April 1st, 2007 03:26 Ngày 01 Tháng Tư 2007 03:26
    1 1

    We can do it also with the query, Chúng tôi có thể làm điều đó cũng với các truy vấn,

    SELECT * INTO newtable FROM existingtable SELECT * INTO newtable TỪ existingtable

    I think its a little bit shorter. Tôi nghĩ một chút của nó ngắn hơn.

Leave a Reply Để lại một trả lời

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> Bạn có thể sử dụng các thẻ: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime = ""> <em> <i> <q <strike> <strong>

Subscribe to comments feature has been disabled. Thuê bao với ý kiến đều đã bị vô hiệu hoá. To receive notification of latest comments posted, subscribe to Để nhận được thông báo mới nhất đăng ý kiến, đăng ký với My Digital Life Comments RSS feed My Digital Life kiến RSS feed or hoặc register to receive đăng ký để nhận được new comments in daily email digest. Các ý kiến mới trong email tiêu hàng ngày.
Custom Search

New Articles Bài viết mới

Incoming Search Terms for the Article Tìm đến các Điều khoản Điều

create table as select tạo bảng như chọn - -- create table select tạo bảng chọn - -- create table as select from tạo bảng như chọn từ - -- create table with select tạo bảng với các lựa chọn - -- create table from select tạo bảng từ chọn - -- db2 create table as select DB2 tạo bảng như chọn - -- create table from select statement tạo bảng từ tuyên bố chọn - -- create table select from tạo bảng chọn từ - -- db2 create table from select DB2 tạo bảng từ chọn - -- create new table tạo bảng mới - -- access create table truy cập tạo bảng - -- create table as select DB2 tạo bảng như DB2 chọn - -- select create table chọn tạo bảng - -- db2 create table select DB2 tạo bảng chọn - -- create table as select tạo bảng như chọn - -- CREATE TABLE USING SELECT STATEMENT CREATE TABLE SỬ DỤNG SELECT STATEMENT - -- create table with data tạo bảng với dữ liệu - -- db2 create table as DB2 tạo bảng như - -- oracle select into new table oracle chọn vào bảng mới - -- all tất cả - -- create table select into tạo bảng chọn vào - -- create table select tạo bảng chọn - -- create a data table tạo một bảng dữ liệu - -- create table into tạo bảng thành - -- MS Access Create table as select MS Access Tạo bảng như chọn - -- create table as select in db2 tạo bảng như chọn trong DB2 - -- access create table as select truy cập tạo bảng như chọn - -- create table as select ms access tạo bảng như truy cập ms chọn - -- MS ACCESS CREATE TABLE SELECT MS ACCESS CREATE TABLE SELECT - -- sqlite create table as select SQLite tạo bảng như chọn - -- create table select db2 tạo bảng chọn DB2 - -- access create table select truy cập tạo ra bảng chọn - -- db2 create table from another table DB2 tạo bảng từ bảng khác - -- sql create table from select statement sql tạo bảng từ tuyên bố chọn - -- Creating tables thru union query in MS access + select into Tạo bảng truy vấn thông qua công đoàn trong MS truy cập + chọn vào - -- oracle create table as select oracle tạo bảng như chọn - -- create table access tạo truy cập bảng - -- create table+select tạo bảng + chọn - -- how to create a data table làm thế nào để tạo một bảng dữ liệu - -- create table using select tạo ra bằng cách sử dụng bảng chọn - -- CREATE TABLE SELECT ACCESS CREATE TABLE SELECT ACCESS - -- create table with data from another table tạo bảng với dữ liệu từ bảng khác - -- create table select as tạo bảng chọn như - -- create table from existing table in Db2 tạo bảng từ bảng hiện có trong DB2 - -- create table as select access tạo bảng như truy cập chọn - -- SQL Insert table data via select statement SQL Chèn bảng dữ liệu thông qua tuyên bố chọn - -- access create table from select truy cập tạo ra bảng từ chọn - -- oracle create backup table oracle tạo bảng sao lưu - -- db2 create table as select from DB2 tạo bảng như chọn từ - -- db2 create table as select * from DB2 tạo bảng như chọn * từ - -- create table (select tạo bảng (chọn - -- select into new table oracle oracle chọn vào bảng mới - -- create table from another table in db2 tạo bảng từ bảng khác trong DB2 - -- create table using select db2 tạo ra bằng cách sử dụng bảng chọn DB2 - -- access create table as truy cập tạo bảng như - -- oracle create table backup oracle tạo sao lưu bảng - -- create table as (select tạo bảng như (chọn - -- create backup table sql sql tạo bảng sao lưu - -- create table from select tạo bảng từ chọn - -- create table from select statement oracle tạo bảng từ oracle cáo chọn - -- create table with select tạo bảng với các lựa chọn - -- ms access create table from select ms truy cập tạo ra bảng từ chọn - -- db2 create table as DB2 tạo bảng như - -- oracle create table select oracle tạo bảng chọn - -- microsoft access create table as select microsoft truy cập tạo bảng như chọn - -- create table another table db2 tạo bảng khác bảng DB2 - -- CREATE TABLE INTO SELECT CREATE TABLE INTO SELECT - -- make a data table online thực hiện một bảng dữ liệu trực tuyến - -- create data table tạo bảng dữ liệu - -- CREATE TABLE AS SELECT ORACLE CREATE TABLE AS SELECT ORACLE - -- create table + select tạo bảng + chọn - -- create a backup table in SQL tạo một bảng sao lưu trong SQL - -- create a table from select statement tạo một bảng từ tuyên bố chọn - -- create table from other table tạo bảng từ bảng khác - -- create backup table in sql tạo bảng sao lưu trong sql - --