Community journal

The latest from the MySQL community

Ideas, releases, practical guides, and perspectives from the people building with MySQL.

Follow the feed
Showing entries 1 to 1 of 1 « Previous | Next »
Displaying posts with tag: vba (reset)
Migrar de MS Access a MySQL con relaciones

He usado herramientas como MySQL Migration Toolkit (*) y Bullzip’s Access To MySQL, ambos hacen un excelente trabajo pero no exporta las relaciones entre tablas. Hacer esta tarea nos puede tomar varias horas (hasta ahora):

Escribí un código VBA para identificar las relaciones generando código MySQL con las sentencias de creación, esto puede ser muy útil después de la migración usando cualquier herramienta libre.

Option Explicit
'Copiar y pegar esta función en un módulo nuevo/existente de MS Access.

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 & "` ," …
[Lea más]