How to duplicate a table with keys & other structure features retained in MySQL?

后端 未结 3 433
无人共我
无人共我 2021-02-03 10:42

How to duplicate a table with keys & other structure features retained? including primary key, foreign keys, and indexes.

Can this be done with a single MySQL query?

3条回答
  •  时光取名叫无心
    2021-02-03 11:22

    you can do it in this query

    CREATE TABLE a LIKE b
    

    after you can insert

    INSERT INTO a SELECT * FROM b
    

    read more information in this article

提交回复
热议问题