Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Location
    Canada
    Posts
    35

    Unanswered: 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;

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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 ... ;

  3. #3
    Join Date
    Jul 2011
    Posts
    5
    Thanks ! Learning DB2...

  4. #4
    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"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •