Okay, I've got two databases, the second one being a more up to date version of the first one. It has new columns, tables, constraints, and whatnot.
I was wondering if there is a solid program out there that will update the first database with all that of the second already updated database (Not the data, just the tables, columns and all that) or am I stuck creating my own update script from scratch?
I actually found another post, that did not look like the same thing but it still helped me anyway, I found a program called Toad for MySQL and it has a compare Schema option that compares the two databases and then can sync one to the other (it creates a script and executes it) it seems to be working flawlessly, but I'm still testing the web app that uses the database to ensure this is true.
If you're on Windows, the RedGate SQL data and schema compare tools are beautiful:
http://mysql-compare.com/info
I've used them a few times. They're quite simple to use.
They're designed around creating DB diffs for moving from dev/QA/staging environments to integration/production environments (so yes, they generate scripts).
If you are looking for a tool that will compare at the schema level then I would suggest Navicat. The older version that I use works well for getting my production and development boxes in synch. I don't recommend it for large levels of data synchronization though - it seems very slow compared to a SQL dump and SQL import.
Related
I'm working with a project which is using mysql as the database. The application is hosted with many clients and we are doing upgrades for the current live systems often.
There are some instances where the client has change the database structure(adding new tables) and causes some unexpected db crashes.
I need to log all the structural changes which were done at that database, so we can find the correct root cause for that. We can't do it 100% correct with diff tool because it will not show the intermediate changes.
I found http://www.liquibase.org/ tool but seems little bit complex.
Is there any well known technique or a tool to track database structural changes only.
well from mysql studio you can generate all object's schema definition and compare them with your standard schema definition and this way you can compare two database schema...
generate scrips of both database (One is client's Database and One is master copy database) and then compare it using file compare tool would be the best practice according to me because this way you can track which collumn was added, which column was deleted, which index was added like wise without any tool download.
Possiable duplication of Compare two MySQL databases ?
Hope this helps.
If you have an application for your clients to manage these schema changes, you can use a mechanism at application level. If you have a Python and Django-based solution, you could probably use South which provides schema change tracking and rollbacks.
I have exported a database and then imported it into a new database. Then I can see that there is a difference in size, which I came to learn that it is due the space reuse issue for deleted entries which is not exported.
So, now two databases should be identical in terms of active (non deleted) entries. But, how can I check that? [system: linux, mysql, phpmyadmin, webmin, etc.]
there are several free and paid tools to do this, both on data and on table structure etc.
most can even generate scripts to sync database a with b.
search google for database compare tool (or something like that)
A simple way of checking if two database schemas are the same is to generate script for each database and compare/diff if the scripts are the same.
I need ability to compare two similar databases. One will be slightly newer than the other and have changes to the structure of the database as well as possibly the content within it.
So far I have tried using liquibase but it doesn't seem to be comparing properly.
I have also tried the MySQL Diff Perl module which works but doesn't consider content.
Main Question:
Does anyone know any solutions that will give back SQL for both structural and content differences and generate a SQL script?
A bit more info:
The intended use for this is when making updates and installing MODs to phpBB so that the forum can be included in the build process along with the rest of our website. Which has a 4 tier process (local, development, staging, production).
When installing the phpBB updates and MODs I will make a dump of the current production database and lock the site so no new data can be added whilst I make changes. That way databases shouldn't come out of sync.
When installing MODs and updates sometimes the database structure changes and also the data within tables, especially when adding things requiring extra permissions etc.
The solution I use therefore will be used to compare the local database with the upgraded changes to the production database, providing me with a script I can run on each tier in the build process, rather than manually installing the update/MOD on each.
You can use SQLyog Database synchronization tool to sync two databases,either one-way or two-way. By far this is the best data comparison tool for MySQL GUI. And, Schema sync for schema comparisons between two databases.
Both tools can generate SQL scripts.
I've actually found a way to do it via Navicat for MySQL using the Tools > Structure Syncronization option.
This will give SQL statements for differences in structure between the two databases.
Then do do the data differences you can use Data Syncornization.
I've managed to copy out the SQL script for differences in structure. However the data syncronization seems to be more of an internal Navicat thing. I'm sure there's a way that the queries could be extracted though.
Please note I'm using a license version so not sure if its available in the free to use one.
I have 2 MySQL servers: one for development, other for production. Both contain same table structure, but different data on tables.
When I have done change on dev server, like add column to table, I have manually made the same change later to production server. But this slow and error prone, especially if there are many changes to be made at once.
Is there better way to do this? I have phpMyAdmin, maybe that has some neat trick?
Also, is there a dedicated term for what this process is called? Searching for 'table update' or similar does not yield results on this topic.
EDIT:
Forgot to mention that I am using Windows.
So apparently I need some kind of diff tool for this. I haven't tested all of these proposed software yet, but so far they seem very useful.
I've used Red Gate's SQL Compare before for SQL Server; this is their MySQL product. I don't have the budget to buy it myself, but if it works anything like SQL Compare did, it'll do exactly what you want it to do.
When ever I do this I have used the data or structure sync in a Mysql GUI app called Navicat, there is a free version available and it does what you asked perfectley.
Try to compare and synchronize databases with schema/data comparers in dbForge Studio for MySQL.
Do you know any applications to synchronize two databases - during development sometimes it's required to add one or two table rows or new table or column.
Usually I write every sql statement in some file and during uploading path I evecute those lines on my production database (earlier backing it up).
I work with mySQL and postreSQL databases.
What is your practise and what applications helps you in that.
You asked for a tool or application answer, but what you really need is a a process answer. The underlying theme here is that you should be versioning your database DDL (and DML, when needed) and providing change scripts to be able to update any version of your database to a higher version.
This set of links provided by Jeff Atwood and written by K. Scott Allen explain in detail what this ought to look like - and they do it better than I can possibly write up here: http://www.codinghorror.com/blog/2008/02/get-your-database-under-version-control.html
For PostgreSQL you could use Another PostgreSQL Diff Tool . It can diff two SQL Dumps very fast (a few seconds on a db with about 300 tables, 50 views and 500 stored procedures). So you can find your changes easily and get a sql diff which you can execute.
From the APGDiff Page:
Another PostgreSQL Diff Tool is simple PostgreSQL diff tool that is useful for schema upgrades. The tool compares two schema dump files and creates output file that is (after some hand-made modifications) suitable for upgrade of old schema.
Have scripts (under source control of course) that you only ever add to the bottom off. That combined with regular restores from your production database to dev you should be golden. If you are strict about it, this works very well.
Otherwise I know lots of people use redgate stuff for SQLServer.
Another vote for RedGate SQL Compare
http://www.red-gate.com/products/SQL_Compare/index.htm
Wouldn't want to live without it!
Edit: Sorry, it seems this is only for SQL Server. Still - if any SQL Server users have the same question I'd definitely recommend this tool.
If you write your SQL statements for your development database (which are, I imagine, series of DDL instructions such as CREATE, ALTER and DROP), why don't you keep track of them by recording them in a table, with a "version" index? You will then be able to:
track your version changes
make a small routine allowing the "automatic" update of your production database by sending the recorded instructions to the database.
I really like the EMS tools.
There tools are available for all popular DB's and you have the same user experience for every type of DB.
One of the tools is the DB Comparer.
TOAD
saved many an ass several times in the past. Why do people run sql with no exit strategy?
the redgate one is good also.
Siebel (CRM, Sales, etc. management product) has a built-in tool to align the production database with the development one (dev2prod).
Otherwise, you've got to stick with manually executed scripts.
Navicat has a structure synchronisation wizard that handles this.
I solve this by using Hibernate. It can detect and autocreate missing tables, columns, etc.
You could add some automation to your current way of doing things by using dbDeploy or a similar script. This will allow you to keep track of your schema changes and to upgrade/rollback your schema as you see fit.
Here's a straight linux bash script I wrote for syncing Magento databases... but you can easily modify it for other uses :)
http://markshust.com/2011/09/08/syncing-magento-instance-production-development
DBV - "Database version control, made easy!" (PHP)