将 mysql 表导出到 ms Access 表的最快/安全的方法

发布于 2024-11-04 09:07:32 字数 284 浏览 1 评论 0原文

我正在寻找一种方法将一些 MySql 表导出到 MsAccess DB 的其他表中(我正在谈论一百万条记录表...)

我想到的唯一两种方法是:

  1. 从 myadmin 导出或toad 一个 csv 文件,然后将其导入到 access 数据库中。

  2. 直接从 Toad 制作“Access 数据库导出”

我发现第一个速度更快,但数据完整性不太安全,而第二个则完美为了数据完整性但非常慢...有人知道其他方法吗?

谢谢 一个。

i'm searching for a way to export some MySql tables into other tables of a MsAccess DB (I'm talking about a million records table...)

the only two way that I thought about are:

  1. export from myadmin or toad a csv file and then import it into the access DB.

  2. making directly from Toad the "Access Database Export"

I'm getting that the first is more fast but less secure for the data integrity, while the second is perfect for the data integrity but very slow ... someone knows other ways?

Thanks
A.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦亿 2024-11-11 09:07:32

在网络服务器上使用 MySQL 数据库运行 Access 前端应用程序的分步指南(您不需要导入表,您可以在网络服务器上使用 msaccess 应用程序与它们):

如果您正在运行 MsAccess,我假设您正在使用 windows

  1. 安装MySQL ODBC 5.1 驱动程序(连接器)http://dev.mysql.com/downloads/connector/odbc/
  2. 在 win 机器上打开控制面板
  3. 管理工具(如果是 Vista 或 7,搜索 ODBC)
  4. 设置数据源 ODBC
  5. 系统 DSN
  6. ADD

根据您的服务器,您可能很难找到服务器名称或 IP,寻找 SSH 数据库连接(或类似的东西)。例如,请阅读 NetSol 的常见问题解答: http://www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/

完成此操作后,在 MsAccess 中:
1. 文件
2. 外部数据源
3.链接表

如果你想从MsAccess导出到MySQL,你可以在access中创建一个表格,在上面放一个按钮,然后在VBA中为OnClick()事件创建这个子:

Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=DSNname;UID=userOnServer;PWD=pwdOnServer"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST"
Resume SmoothExit_ExportTbls

有时,在运行非英语窗口时,你可以可能会出现错误 2507,请将“ODBC 数据库”更改为“ODBC”(适用于法语)。

step by step guide to running Access frontend application with MySQL database on webserver (you dont need to IMPORT the tables, you can use your msaccess application WITH them on the webserver):

If you are running MsAccess, i suppose that you are using windows

  1. Install MySQL ODBC 5.1 Driver (connector) http://dev.mysql.com/downloads/connector/odbc/
  2. Open CONTROL PANEL on win machine
  3. ADMINISTRATIVE TOOLS (if Vista or Seven, search ODBC)
  4. SET UP DATA SOURCES ODBC
  5. SYSTEM DSN
  6. ADD

depending on your server, you might have some difficulty finding the server name or IP, look for SSH Database connection (or something like that). as an example, read NetSol's FAQ: http://www.networksolutions.com/support/how-to-back-up-the-mysql-database-using-ssh/

once you have done that, in MsAccess:
1. FILES
2. EXTERNAL DATA SOURCE
3. LINK TABLES

if you want to EXPORT to MySQL from MsAccess, you can create a FORM in access, put a button on it, and in VBA create this sub for the OnClick() event:

Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=DSNname;UID=userOnServer;PWD=pwdOnServer"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure ExportTblsODST"
Resume SmoothExit_ExportTbls

sometimes, while running non-english windows you might get error 2507, change "ODBC Database" for "ODBC" (works with French).

夜灵血窟げ 2024-11-11 09:07:32

如果您具有对 MySQL 的 ODBC 访问权限,并且您的服务器位于网络上,则可以从 Access 中导入其表。我认为菜单选择是“文件|获取外部数据|导入”。

对于“文件类型”,选择“ODBC 数据库”。您可能需要创建新的 DSN 名称。

我不记得 ODBC 驱动程序通常是默认安装的,还是单独安装的。我认为它们是默认安装的,但我可能是错的。

If you have ODBC access to MySQL, and your server is on your network, you can import its tables from within Access. I think the menu selections are "File | Get external data | Import".

For "Files of type", select "ODBC Databases". You might need to create a new DSN name.

I can't recall whether ODBC drivers are generally an installation default, or whether they're a separate install. I think they're installed by default, but I could be wrong.

诠释孤独 2024-11-11 09:07:32

感谢托尼提供了这个很棒的节省时间的脚本。由于我用前缀“tbl”命名表,因此我修改了代码,因此它只会导出这些表(而不是那些看起来很奇怪的表):

Private Sub Command0_Click()
Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef
Dim str As String

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=proxmox decaoriginal;UID=matantan;PWD=majadero5"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

str = "tbl"

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
If Left(tbldef.Name, 3) = str Then
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Else
End If
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure  ExportTblsODST"
Resume SmoothExit_ExportTbls
End Sub

Thanks tony for that awesome time-saving script. Since I name my tables with the prefix "tbl", I modified the code so it will only export those tables (not the weird looking ones):

Private Sub Command0_Click()
Dim sTblNm As String
Dim sTypExprt As String
Dim sCnxnStr As String, vStTime As Variant
Dim db As Database, tbldef As DAO.TableDef
Dim str As String

On Error GoTo ExportTbls_Error

sTypExprt = "ODBC Database"
sCnxnStr = "ODBC;DSN=proxmox decaoriginal;UID=matantan;PWD=majadero5"
vStTime = Timer
Application.Echo False, "Visual Basic code is executing."

str = "tbl"

Set db = CurrentDb()

For Each tbldef In db.TableDefs
Debug.Print tbldef.Name
If Left(tbldef.Name, 3) = str Then
sTblNm = tbldef.Name
DoCmd.TransferDatabase acExport, sTypExprt, sCnxnStr, acTable, sTblNm, sTblNm
Else
End If
Next tbldef

MsgBox "Done!"
On Error GoTo 0
SmoothExit_ExportTbls:
Set db = Nothing
Application.Echo True
Exit Sub

ExportTbls_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure  ExportTblsODST"
Resume SmoothExit_ExportTbls
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文