I have used tools like MySQL Migration Toolkit (*) and Bullzip’s Access To MySQL utility, both do a excellent job but without relationships. We can spend a lot of hours to identifying and creating relationships until now:
I have write a VBA script to identify MS-Access relationships and create MySQL code with SQL-CREATE sentences, it will be useful after migration process using any free tool:
Option Explicit 'Put this function in new/existing MS-Access module. Public Sub printRelations() Dim sql, fk As String Dim i, j As Integer For i = 0 To CurrentDb.Relations.Count - 1 sql = "ALTER TABLE `" & CurrentDb.Relations(i).ForeignTable & _ "` ADD CONSTRAINT `" & CurrentDb.Relations(i).Name & "` FOREIGN KEY (" fk = "(" For j = 0 To CurrentDb.Relations(i).Fields.Count - 1 sql = sql & "`" & CurrentDb.Relations(i).Fields(j).ForeignName & "` ," fk = fk & "`" & CurrentDb.Relations(i).Fields(j).Name & "` ," Next j sql = Left(sql, Len(sql) - 1) fk = Left(fk, Len(fk) - 1) fk = fk & ")" sql = sql & ") REFERENCES `" & CurrentDb.Relations(i).Table & "`" & fk & ";" Debug.Print sql Next i End Sub
To run the adobe code go to intermediate windows (Ctrl+G) and execute: printRelations and copy the generated SQL code.
Enjoy!
(*)MySQL Migration Toolkit is discontinued but is still available from mirrors like:
http://mirrors.dotsrc.org/mysql/Downloads/MySQLGUITools/
Related Posts :
I just finished a database modification, a new foreign key creation shouldn't be take more than ...
Do you get write laziness in the command line everything what you need to connect to a MySQL ser ...
bmon is a useful network monitoring tool, the most useful feature is that bmon store historical ...
Some days ago while I'm looking for what are saying about a mysql.com server down I found a twit ...
From command line we have the entire MySQL server on hands (if we have privileges too of course) ...

hi, great tool! i’m getting the following error, though:
Compile error: Expected variable or procedure, not module. what am i doing wrong? am using msa2010. thanks much!woops, solved it by following http://support.microsoft.com/kb/312851 – just renamed the sub to something else. thanks much! you saved me money today, man!