How to copy table in MYSQL with indexes

Discussion in 'MySQL' started by deriklogov, Jul 20, 2009.

  1. #1
    Hey, I been using
    CREATE TABLE IF NOT EXISTS ttt SELECT * FROM temp

    but I found out that this query doesnt copy indexes and extra options like "auto increment"

    What you could suggest ?
     
    deriklogov, Jul 20, 2009 IP
  2. nirajkum

    nirajkum Active Member

    Messages:
    815
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #2
    you will have to seperately export the index ... with sqldump and import those sql file
     
    nirajkum, Jul 21, 2009 IP
  3. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    create table A like B;
    insert into A select * from B;

    Should copy index and all IIRC.
     
    Goramba, Jul 22, 2009 IP