Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Location
    Italy
    Posts
    11

    Unhappy Unanswered: table as select..

    Hi all,
    I'm a newby db2 dba, but a little expert from oracle..
    I'm simply tring to create a new table from another pre-existing one using a statement like this:

    create table tab_name
    as select * from other_table

    But db2 give me the classic syntax error sql0104n..

    The questions are:

    Can I create a table from an existing one with same structure and data like in oracle?

    If so, what is the right syntax?

    Thanks in advance
    downtown

  2. #2
    Join Date
    Dec 2003
    Location
    Italy
    Posts
    11

    Re: table as select..

    Please anybody can help me?

    Originally posted by downtown
    Hi all,
    I'm a newby db2 dba, but a little expert from oracle..
    I'm simply tring to create a new table from another pre-existing one using a statement like this:

    create table tab_name
    as select * from other_table

    But db2 give me the classic syntax error sql0104n..

    The questions are:

    Can I create a table from an existing one with same structure and data like in oracle?

    If so, what is the right syntax?

    Thanks in advance
    downtown

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    In DB2 you need to do it as a two step process. First create the table, then insert the data.

    CREATE TABLE MyTable2 like MyTable1
    INSERT INTO MyTable2 select * from MyTable1;

    HTH

    Andy

  4. #4
    Join Date
    Dec 2003
    Location
    Italy
    Posts
    11
    Thank you so much Andy

    Originally posted by ARWinner
    In DB2 you need to do it as a two step process. First create the table, then insert the data.

    CREATE TABLE MyTable2 like MyTable1
    INSERT INTO MyTable2 select * from MyTable1;

    HTH

    Andy

Posting Permissions

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