View previous topic :: View next topic
|
Author |
Message |
l.nethaji
New User
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
|
|
|
|
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 |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
You can use definition only clause to copy the table structure. For data you will have to insert them using Select. |
|
Back to top |
|
|
l.nethaji
New User
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
|
|
|
|
"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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1020 Location: India
|
|
|
|
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 |
|
|
l.nethaji
New User
Joined: 16 Mar 2008 Posts: 90 Location: tamil nadu
|
|
|
|
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 |
|
|
cmsmoon
New User
Joined: 17 Jun 2010 Posts: 75 Location: Chennai
|
|
|
|
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 |
|
|
|