CREATE TABLE AS

Name

CREATE TABLE AS  --  Creates a new table built from data retrieved by a SELECT.

Synopsis

CREATE TABLE table [ (column [, ...] ) ]
     AS select_clause
  

Parameters

table

This parameter takes the name of the new table being created.

column

This parameter takes the name of a column; you can specify multiple columns by including them in a comma-delimited list.

select_clause

This parameter takes a valid query statement.

Results

For a listing of possible output messages for this command, refer to CREATE TABLE and SELECT.

Description

Use the CREATE TABLE AS command to create a table from the contents of a table that already exists within the database. The data for the new table comes from a select command that dumps all of the data into the new table once it is acquired. This command is similar to SELECT.

Examples

The following example creates a condensed table (aptly named condensed_books) from two columns taken from the books table.

   CREATE TABLE condensed_books 
       AS SELECT id, title 
            FROM books;