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
 

 

Creating a duplicate table like existing

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Bhagyalakshmi C

New User


Joined: 24 Jul 2007
Posts: 38
Location: Bangalore

PostPosted: Mon Sep 03, 2007 4:41 pm    Post subject: Creating a duplicate table like existing
Reply with quote

Hi,

I want to create a duplicated table.
I am having a table "TABLE1" and i need to create another table "TABLE2" with all the records in the "TABLE1".

I think this can be done using Load and unload utilities.
Please let me know if there is any other method.

Thanks all!!!
Back to top
View user's profile Send private message

Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Mon Sep 03, 2007 5:10 pm    Post subject:
Reply with quote

If you have QMF and then the number of records are only a few..

you could use select * from TABLE1 in qmf panel and you can issue the command 'save data as TABLE2' (Note that table2 will be created under your id only).

Thanks,
Prajesh
Back to top
View user's profile Send private message
Bhagyalakshmi C

New User


Joined: 24 Jul 2007
Posts: 38
Location: Bangalore

PostPosted: Mon Sep 03, 2007 5:19 pm    Post subject:
Reply with quote

you can issue the command 'save data as TABLE2'

Where i have give this??

Thanks!!!!
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Mon Sep 03, 2007 5:22 pm    Post subject:
Reply with quote

Give it in QMF command line...
Back to top
View user's profile Send private message
Bhagyalakshmi C

New User


Joined: 24 Jul 2007
Posts: 38
Location: Bangalore

PostPosted: Mon Sep 03, 2007 5:23 pm    Post subject:
Reply with quote

should it be like this

Code:

select * from table1 save data as table2


this is not working getting error!!!
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Mon Sep 03, 2007 5:27 pm    Post subject:
Reply with quote

As an answer to interview question-
Code:
1. CREATE TABLE2 LIKE TABLE1
2. INSERT INTO TABLE2 (SELECT * FROM TABLE1)
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Mon Sep 03, 2007 5:28 pm    Post subject:
Reply with quote

select * from table1
in the query panel..then execute the query...after that issue command "save data as table2" in QMF command line..

Thanks,
Prajesh
Back to top
View user's profile Send private message
Bhagyalakshmi C

New User


Joined: 24 Jul 2007
Posts: 38
Location: Bangalore

PostPosted: Tue Sep 04, 2007 11:28 am    Post subject:
Reply with quote

Thanks Prajesh..

I got it!!

icon_smile.gif

Thank you!!
Back to top
View user's profile Send private message
Bhagyalakshmi C

New User


Joined: 24 Jul 2007
Posts: 38
Location: Bangalore

PostPosted: Tue Sep 04, 2007 11:38 am    Post subject:
Reply with quote

Thanks Abhijit!!!!

Quote:

As an answer to interview question-
Code:
1. CREATE TABLE2 LIKE TABLE1
2. INSERT INTO TABLE2 (SELECT * FROM TABLE1)


This is not working!!
can you please explain me!!!

Thank you!!!
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Tue Sep 04, 2007 11:48 am    Post subject:
Reply with quote

!!! icon_confused.gif
Explain you what?

Only 'This is not working!! ' does not tell me anything about problem you got in your query. Please explain your problem..
Back to top
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Thu Sep 06, 2007 11:43 am    Post subject: Reply to: Creating a duplicate table like existing
Reply with quote

Hi,

r u trying to execute both queries at a time in QMF?
Back to top
View user's profile Send private message
karnataka

New User


Joined: 15 Sep 2006
Posts: 20
Location: bangalore

PostPosted: Thu Sep 06, 2007 11:43 am    Post subject: Reply to: Creating a duplicate table like existing
Reply with quote

Hi,

r u trying to execute both queries at a time in QMF?
Back to top
View user's profile Send private message
Bhagyalakshmi C

New User


Joined: 24 Jul 2007
Posts: 38
Location: Bangalore

PostPosted: Thu Sep 06, 2007 4:14 pm    Post subject:
Reply with quote

Hi,

No.. not at the same time..one after the other only..

It should be..

CREATE TABLE TABLE2 LIKE TABLE1

the "TABLE" key word is missing.. so did not get..

any way the second query i am not getting..

Thank you!!!
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Fri Sep 07, 2007 5:10 pm    Post subject:
Reply with quote

Quote:
any way the second query i am not getting

You haven't understood or
dies it mean you are not getting any error?
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 Using ICETOOL, how we can seperate th... bshkris SYNCSORT 5 Tue May 09, 2017 8:33 pm
No new posts unload data from table with lob columns farhad_evan DB2 0 Sat Apr 22, 2017 1:32 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 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


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