Home » SQL & PL/SQL » SQL & PL/SQL » to create a table structure from an existing structure
to create a table structure from an existing structure [message #35976] Sun, 28 October 2001 01:00 Go to next message
sini
Messages: 10
Registered: October 2001
Junior Member
hi
consider i have a table 'item' with
the following structure
item_code varchar2(4),qty number(2)
with say around 3 records

now i want to create another table 'item_temp'
which has the SAME STRUCTURE as the above table
but i DO NOT WANT THE DATA FROM THE TABLE 'item'.

if i give the statement
CREATE TABLE item_temp
AS (SELECT * FROM item),
the structure and the contents of the table 'item'
is adopted for table 'item_temp'.
I DON'T WANT THAT.I just want the structure
of the table 'item' to the table 'item_temp'.

Eventually i want to have 'item' with 3 records and 'item_temp' with the same structure as 'item'
but with no records.

what is the sql statement for that?

YA...I COULD USE THE CREATE STATEMENT AS ABOVE
AND THEN DELETE THE RECORDS FROM 'item_temp'.
BUT I DON'T PREFER THAT.IS THERE ANY OTHER SQL
STATEMENT THAT CAN BE USED FOR THIS???

THANX IN ADVANCE

SINI

----------------------------------------------------------------------
Re: to create a table structure from an existing structure [message #36032 is a reply to message #35976] Tue, 30 October 2001 23:37 Go to previous message
Satish Shrikhande
Messages: 167
Registered: October 2001
Senior Member
Hi

CREATE TABLE item_temp
AS (SELECT * FROM item
where columnname=value);

Put some value in where condition like value=null so that query doesn't fetch any data and then you will get the item_temp with no data .

Enjoy !!

----------------------------------------------------------------------
Previous Topic: Re: SELECT with variables
Next Topic: Please advice on my first PL-SQL code
Goto Forum:
  


Current Time: Thu Apr 18 01:26:11 CDT 2024