IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

copy a table structure to another


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Mon Jun 14, 2010 6:27 pm
Reply with quote

Hi,

I am trying to copy table t2 to table t5 using the below query.

create table t5 as (select * from t2).

Its throws error.

IS ther any other query which copies both the structure and data.

If i create t5 and insert using select * from t2 it works.

Please clarify and please let me know how to copy the table structure using DB2 .

Thanks,
L.Nethaji
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Mon Jun 14, 2010 6:45 pm
Reply with quote

You can use definition only clause to copy the table structure. For data you will have to insert them using Select.
Back to top
View user's profile Send private message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Mon Jun 14, 2010 9:04 pm
Reply with quote

"You can use definition only clause to copy the table structure"

Can you please let me know how to copy the table structure alone without the data.

Thanks ,
L.Nethaji
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 14, 2010 9:47 pm
Reply with quote

depends on what tools or method you want to use.

by hand, copy the create ddl of the existing table to another member,
change the name of the table,
run the sql thru spufi.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jun 14, 2010 10:42 pm
Reply with quote

Nethaji,

You can do it like this,
Code:
CREATE TABLE BOBT1.TRY3 LIKE BOBT1.TRY2 ;


I like to know, what's your plan for tablespace.

Thank You,
Sushanth
Back to top
View user's profile Send private message
l.nethaji

New User


Joined: 16 Mar 2008
Posts: 90
Location: tamil nadu

PostPosted: Tue Jun 15, 2010 12:09 pm
Reply with quote

Hi guys ,

thanks for the information .

Sushanth ,

Just i am looking for the syntax of the copying a table structure as u gave it.

the information u people gave is really useful.

regards,
l.nethaji
Back to top
View user's profile Send private message
cmsmoon

New User


Joined: 17 Jun 2010
Posts: 75
Location: Chennai

PostPosted: Fri Jun 18, 2010 10:26 pm
Reply with quote

CREATE TABLE NEW_TABLE_NAME LIKE OLD_TABLE_NAME;


if u want to insert one table record to another table


insert into new_table_name values(select * from old_table_name);
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top