Domanda

Al momento ho un database in MySQL, che vorrei importare in MS Access.

È possibile farlo mantenendo intatte tutte le relazioni (cioè senza esportare in .csv o utilizzando ODBC)?

Sono un noob in questo settore, quindi qualsiasi aiuto è molto apprezzato.

Grazie.

È stato utile?

Soluzione

Devi risolvere due diversi problemi:

  1. Creazione di un database MS Access vuoto con una struttura che corrisponde alla struttura del database MySQL.

  2. Estrazione dei dati da MySQL e caricamento in MS Access.

Questo non è facile perché diversi database SQL offrono diverse caratteristiche strutturali, diversi tipi di dati e così via. Più complesso è il tuo utilizzo di MySQL, più è probabile che ti imbatterai in qualche show-stopper durante la conversione (ad esempio, Access non supporta affatto i trigger). Al contrario, se stai usando MySQL come un semplice archivio di dati, potresti trovare la conversione abbastanza facile.

Per ottenere un database MS Access con la stessa struttura del database MySQL, la soluzione migliore è trovare uno strumento di definizione / creazione di diagrammi di database che offra il reverse engineering e supporti sia MySQL che MS Access. Usalo per decodificare il tuo database MySQL in un diagramma di database, quindi modifica il database sottostante in MS Access e utilizza lo strumento per generare un database.

Dai un'occhiata a Dezign For Databases che (sulla carta, comunque) offre le funzionalità di cui avresti bisogno fallo.

Per pompare i dati, sono disponibili numerosi strumenti. Questo tipo di operazione viene genericamente indicato come ETL (Extract, Translate, Load).

Altri suggerimenti

Do you mean SQL Server? A good starting point might be to check out SQL Server Integration Services (SSIS), which can be used for transferring data around like that.

Google will also be helpful, check out the first result:

http://support.microsoft.com/kb/237980

By the way, you said ".sql" in your question: a .SQL file is a script file, which could do anything from create a database, insert data, drop table, delete data, or given the right permissions, call system procedures and reboot a machine, format a drive, send an email.. Just for ref, .SQL files aren't the storage format used by SQL Server.

While you can script your database's schema into script files via something like SQLyog, you will find that the syntax varies enough from database to database (MySQL to Access, in your case) that you can't directly apply the scripts.

With much effort a conversion script could be created by editing the script (perhaps automated with a program, depending on the resulting script size). I think you would be better served using ODBC to copy the tables (and data) and then extracting and re-applying the relationships from the generated script by hand. Time consuming, but also a one time operation I would hope.

When both systems are the same database, there are tools that can do the comparison and script generation (TOAD for MySQL and RedGate Compare for Microsoft SQL), but they don't do cross database work (at least not the ones I am aware of).

If you create a ODBC DSN, you can use TransferDatabase to import from your MySQL database. You can do it manually with the GET EXTERNAL DATA command (or whatever it is in A2007/A2010) and see how well it works. It won't get all data types exactly right, but you could do some massaging and likely get it closer to what will work best.

Is there some reason you can't just link to the MySQL tables and use them directly? That is, why do you need to import into Access at all?

You can try using this: Converting MS Access to MySQL with relationships

Works fine and export all relationships.

Access: run query. Just make sure to adapt the SQL code since every RDMS has its own sintaxis (despite SQL being an ANSI standard).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top