Loading ...
Sorry, an error occurred while loading the content.
 

RE: [SQLQueriesNoCode] How to copy the structure of the table

Expand Messages
  • John Warner
    CREATE NewTable LIKE OldTable; Should just get the structure. I am moderately sure the LIKE clause is supported by DB2, but don t have access to DB2 so cannot
    Message 1 of 9 , Nov 30, 2005
      Message
      CREATE NewTable LIKE OldTable;
       
      Should just get the structure. I am moderately sure the LIKE clause is supported by DB2, but don't have access to DB2 so cannot test.
       
       
      John Warner
      -----Original Message-----
      From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of paul a
      Sent: Wednesday, November 30, 2005 11:41 AM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: RE: [SQLQueriesNoCode] How to copy the structure of the table

      Hi,
       
      Actually i tried "select * into..." but it didnt work out for DB2. Is there any other way to copy the structure of one table into other?
       
      Thanks,
      Paul

      John Warner <john@...> wrote:
      On the other hand, that is just one field that would need appending.
       
       
      John Warner
      -----Original Message-----
      From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Jeff Palmer
      Sent: Monday, November 28, 2005 4:58 PM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: RE: [SQLQueriesNoCode] How to copy the structure of the table

      The one problem I think I’ve encountered with ‘select into’ was losing my ‘identity fields’.  If I had an auto-increment-id field, that was lost from the ‘select into’
       
      Jeff Palmer
       

      From: Michael Weiss [mailto:mweiss@...]
      Sent: Monday, November 28, 2005 4:39 PM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: RE: [SQLQueriesNoCode] How to copy the structure of the table
       
      Not sure about DB2 but in Sql Server you can do a “SELECT * INTO mynewtable FROM mytable WHERE 1=2” and get only the structure and no data.
      HTH,
      Michael
       

      From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Jeff Palmer
      Sent: Monday, November 28, 2005 1:32 PM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: RE: [SQLQueriesNoCode] How to copy the structure of the table
       
      I’m not sure about DB2 but some systems will create a ‘script’ for your table generation.  You can copy this script, change the name of the table created in the script, then run the sql code which will create your new table with the exact same structure.
       
      Jeff Palmer
      E-Commerce Manager
      Ohio Wholesale, Inc.
      330-769-1042
       

      From: paul a [mailto:itsavm_paul_useful@...]
      Sent: Monday, November 28, 2005 9:52 AM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: [SQLQueriesNoCode] How to copy the structure of the table
       
      Hi,
       
      Could any one help me about how to copy the structure of the table (only the structure not the table records) in DB2?
       
      Thanks and Regards,
      Paul



      Yahoo! Personals
      Single? There's someone we'd like you to meet.
      Lots of someones, actually. Yahoo! Personals

    • Ruffin Bailey
      On 11/29/05 6:01 AM, SQLQueriesNoCode@yahoogroups.com ... Unf. not much use for the OP, but SQL Server can do you one better than that. If you highlight the
      Message 2 of 9 , Dec 2, 2005
        On 11/29/05 6:01 AM, "SQLQueriesNoCode@yahoogroups.com"
        <SQLQueriesNoCode@yahoogroups.com> wrote:
        > Not sure about DB2 but in Sql Server you can do a "SELECT * INTO
        > mynewtable FROM mytable WHERE 1=2" and get only the structure and no
        > data.

        Unf. not much use for the OP, but SQL Server can do you one better than
        that. If you highlight the table(s) you want in Project Manager (argh, not
        in front of me and I'm forgetting if that's the name) and hit ctrl-c, you'll
        get the SQL for creating the table(s) in your clipboard, ready to post into
        a text editor, Query Analyzer, SQuirreL SQL, whatever, with pretty much
        everything the rdbms knows about their creation.

        Ruffin Bailey
      Your message has been successfully submitted and would be delivered to recipients shortly.