Jimmathy
Jimmathy

Reputation: 327

Can you add an existing table to an existing model in MySQL Workbench?

I'm working with MySQL Workbench and really like the Model feature, but what do I do if I create a Model and forget a table? Can you add an existing table to a model you're working in or do you have to start from scratch and re-import every time? I haven't seen any answers after some initial googling. Thank you in advance for the assistance!

Upvotes: 6

Views: 5017

Answers (4)

Ethan Liew
Ethan Liew

Reputation: 111

Hope it helps

  • select existing database and open with Mysql Workbench
  • menu > Database > Reverse Engineer
  • select your staging db source > next
  • select your staging db database > next
  • Import Mysql tables object ( on the left panel is those tables you want to import to models ) > execute
  • Save your model and EER diagram

Upvotes: 1

René Nyffenegger
René Nyffenegger

Reputation: 40613

Copy the table you want to place in the model from the model with ctrl-c and place it to the EER diagram with ctrl-v.

Upvotes: 4

Thierry_S
Thierry_S

Reputation: 1616

Go to Database menu, Synchronize Model, follow the wizard, but on the "Select Changes to Apply" step, make sure you change the arrow direction to "Update Model". You can either double click on the arrow to change it, or click the button "Update Model". You have to do this for each object. If you just add one table, "Ignore" all of the changes, and just select the one table and choose "Update Model" for it. Image borrowed from google image search: enter image description here

Upvotes: 5

Mike Lischke
Mike Lischke

Reputation: 53582

By "existing table" you probably mean a table that is defined in an SQL file or a database, right? MySQL Workbench comes with a synchronization features, which allows to keep a model and/or a MySQL source in synch. It's a two-way tool, which allows detailed settings what to synch how. So, when you have created your model from an sql file or a MySQL server, you can any time synchronize it with that source again to take over changes (e.g. added tables).

For that you start synchronization with any source: enter image description here

and then pick a db server or an sql file as source and target. You can even save the changes in an alter script, e.g. to reapply it to multiple servers or for archiving purposes.

enter image description here

Upvotes: 0

Related Questions