If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 equivalent of Oracle Create table ... as select ...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-29-03, 13:13
dlafreni dlafreni is offline
Registered User
 
Join Date: Jun 2003
Location: Canada
Posts: 35
DB2 equivalent of Oracle Create table ... as select ...

Is their a direct equivalent in DB2 to create a table with a select ?

in Oracle it goes somethng like this:

create table newtable as Select * from mytable;
Reply With Quote
  #2 (permalink)  
Old 10-29-03, 13:59
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
This was discussed recently. I don't recall all the options, but you can do it with these 2 SQL statements using begin atomic (if needed):

Create table new_table like old_table;
Insert into new_table select * from old table ... ;
Reply With Quote
  #3 (permalink)  
Old 08-02-11, 04:01
abhay_bc abhay_bc is offline
Registered User
 
Join Date: Jul 2011
Posts: 5
Thanks ! Learning DB2...
Reply With Quote
  #4 (permalink)  
Old 08-02-11, 04:41
prakash56 prakash56 is offline
Registered User
 
Join Date: Jan 2004
Location: UK
Posts: 11
Following should also work

db2 "create <NEWTABLE> as (select * from <EXISTINGTABLE) definition only "

db2 "create <NEWTABLE> as (select * from <EXISTINGTABLE) WITH NO DATA"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On