Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

copy a table structure to another

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: copy a table structure to another
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    Post subject:
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    Post subject: hi
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    Post subject:
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: 1013
Location: India

PostPosted: Mon Jun 14, 2010 10:42 pm    Post subject:
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    Post subject: Reply to: copy a table structure to another
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: 72
Location: Chennai

PostPosted: Fri Jun 18, 2010 10:26 pm    Post subject: Reply to: copy a table structure to another
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us