#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    2
    Rep Power
    0

    Question How can I copy just the MySQL database structure (without data) to a new database?


    (Setup: MySQL 3.23.42 on FreeBSD 4.4)

    There is an existent MySQL database on the server with data in it. How can I clone (just) the database structure to a new MySQL database on the same server, but without copying all the data in it?

    Basically, the result should be an identical database, with a different name, with the same table structure, with everything else the same, BUT with empty tables.

    I am open for any solution, simple or complicated.

    Thanks in advance!
  2. #2
  3. 11
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jul 2001
    Location
    Lynn, MA
    Posts
    4,635
    Rep Power
    87
    mysqldump would be the easiest way to do it. Read the man page, particularly about the -d option.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    4
    Rep Power
    0

    mysql copy table structure [+data]


    the easiest way to copy a table with structure and data is:
    CREATE TABLE table1_copy
    SELECT * FROM table1
    WHERE 1=1

    to copy only the structure use:
    CREATE TABLE table1_copy
    SELECT * FROM table1
    WHERE 1=0

    remko caprio
    http://www.szirine.com

IMN logo majestic logo threadwatch logo seochat tools logo