Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alter database to match model

Originally, I used Data Modelling in MySQL Workbench to design a database consisting of a series of tables (i.e. the columns and relationships).

Then using Database -> Forward Engineer, I created a database, and inserted data into the tables.

Now I've realised that the model I've designed needs some changes, and so I've altered some tables by inserted columns. My question is, how do I get MySQL Workbench to alter the tables?

Using Database -> Synchronize Model, Update Source just generates a bunch of CREATE TABLE IF NOT EXISTS sql statements, and as the tables exist, nothing changes.

like image 374
Zeophlite Avatar asked Feb 08 '11 08:02

Zeophlite


People also ask

How do I change database compatibility?

It's really simple to change the database compatibility level. In SQL Server Management Studio (SSMS), right-click on the database name, select Properties, select the Options node, click on the drop-down next to Compatibility level and select the level that matches your SQL Server.

How do I find the compatibility level of a database?

Right-click the database, and then select Properties. The Database Properties dialog box opens. In the Select a page pane, select Options. The current compatibility level is displayed in the Compatibility level list box.

How do I change the compatibility level for all databases in SQL Server?

Use ALTER DATABASE to change the compatibility level of the database.

What is AutoClose in SQL?

AutoClose is a database option or setting – set on a database by database basis (meaning that it can't be controlled at the server level). According to Books Online: When set to ON, the database is shut down cleanly and its resources are freed after the last user exits.


2 Answers

What you are looking for is in the model menu Database / Synchronize model.

like image 84
David Avatar answered Oct 22 '22 06:10

David


As I couldn't get get File -> Export -> Forward Engineer SQL ALTER Script to work, so I made a backup of the data, dropped the tables, recreated them, and then imported the data. I'd rather find a way to get MySQL Workbench to generate ALTER commands from the changes in my model

like image 41
Zeophlite Avatar answered Oct 22 '22 05:10

Zeophlite