0

Is it possible to copy all my DB tables to another DB but without the field values. Soo an empty DB just with tables names and links.

My situation :

I'm developing a web page with a DB(MySql Workbench) in parallel. In that DB I put only fake information and did on local on my PC.

Soo now its time to do it in real with real information >< Soo I wanna tranfert only the tables of my DB in the new server, a copy wouldn't be fine becaucse it will copy also all the fake values :/

Soo is it possible ?

ps : I can't delete all my values because of all PK et FK constraint I declared -_-

2
  • If you're very good with SQL you could copy the system-catalog, which copies the schema of the tables, but not the data. And there are most likely tools to do the same... Commented Aug 1, 2014 at 11:24
  • I don't use workbench but I'd be surprised if this wasn't a simple setting within the export tools. Commented Aug 1, 2014 at 11:27

3 Answers 3

1

There are several ways to go about this.

  1. Use SHOW CREATE TABLE db.tableName; to get the structure of the table, repeat for all tables needed.

  2. Use MySql dump to dump the table structure which looks like this

    mysqldump -d -h localhost -u root -p databasename > dumpfile.sql

Sign up to request clarification or add additional context in comments.

3 Comments

I'm to scared to use the mysqldump >< I will go with the "show create table", Thx ^^
Is it normal I get : ENGINE=InnoDB AUTO_INCREMENT=317 DEFAULT CHARSET=utf8 at the end of each result ?
Yes, the ENGINE is what tells mysql which Storage Engine to use, AUTO_INCREMENT tells MySql what value to start the AUTO_INCREMENT at (you can change this to AUTO_INCREMENT=1 if needed), CHARSET tells MySql how you are going to store text in the database, in this case utf8. Read up on character encoding here.
0

You could use mysqldump with the no-data option

mysqldump --no-data

mysqldump

--no-data, -d

Do not write any table row information (that is, do not dump table contents). This is useful if you want to dump only the CREATE TABLE statement for the table (for example, to create an empty copy of the table by loading the dump file).

Comments

0

You can make a dump from your database without data. See the mysql documentation. There is a switch --no-data which dumps only the table structure:

--no-data, -d

Do not write any table row information (that is, do not dump table contents). This is useful if you want to dump only the CREATE TABLE statement for the table (for example, to create an empty copy of the table by loading the dump file).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.