1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Use putty to copy a mysql table??

Discussion in 'MySQL' started by 123GoToAndPlay, May 16, 2009.

  1. #1
    Hi all,

    Is it possible to use putty to copy a mysql table (struc + data). So far i just know how to show the tables with

    mysql> show tables;
    Code (markup):
    i tried

    mysql> copy table1 tableCopy
    Code (markup):
    without success

    Any suggestions?

    i can't use phpmyadmin as it gives me an error when i tried to copy the table.
     
    123GoToAndPlay, May 16, 2009 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    You can do this by the following 2 commands. It might take some time to copy depending on the table size
    CREATE TABLE tableCopy LIKE table1;
    INSERT INTO tableCopy SELECT * FROM table1;
    Code (markup):
     
    mwasif, May 16, 2009 IP
  3. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Wow, that would be awesome. Gonna try it out.

    Your query is way shorter than phpmyadmin query for copying and inserting table data.
     
    123GoToAndPlay, May 16, 2009 IP
  4. 123GoToAndPlay

    123GoToAndPlay Peon

    Messages:
    669
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    oh man, that works like charm and damn fast too.

    tx for sharing.

    btw:
    any way to exclude the id auto increment column in
    
    INSERT INTO tableCopy SELECT * FROM table1;
    
    Code (markup):
    
    INSERT INTO tableCopy SELECT *,(NOT table1.id) FROM table1;
    
    Code (markup):
     
    123GoToAndPlay, May 16, 2009 IP
  5. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #5
    Glad to help you!!!
     
    mwasif, May 16, 2009 IP