Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to create a duplicate table using sql

Re: how to create a duplicate table using sql

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Tue, 07 Dec 2004 21:56:46 -0800
Message-ID: <1102485300.914734@yasure>


db2group88_at_yahoo.com wrote:

> we are using oracle 10g. I would like to know if there is a sql command
> on oracle could allow to create a duplicate table. On DB2, we can do
> " create table B like table A", please advise. Thanks

The answers other posted:

CREATE TABLE new_table
TABLESPACE userdata
AS SELECT * FROM my_table;

will get you the table plus its data.

If you want the table structure without the data then:

CREATE TABLE new_table
TABLESPACE userdata
AS SELECT * FROM my_table
WHERE 1=2; or any other WHERE clause that evaluates to FALSE.

Modifying the SELECT statement allows for the creation of tables based on part of and/or multiple tables including the creation of columns based on literals.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Tue Dec 07 2004 - 23:56:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US