mysql中删除数据库中的表格数据恢复_恢复从数据库中删除的表

恢复从数据库中删除的表Recover tables deleted from a database

09/25/2018

本文内容

本主题演示如何创建一个示例 Visual Basic for Applications (VBA) 函数, 在以下情况下, 您可以使用它来恢复从 Access 数据库中删除的表:This topic shows how to create a sample Visual Basic for Applications (VBA) function that you can use to recover tables deleted from an Access database under the following conditions:

自删除表以来,数据库尚未关闭。The database has not been closed since the tables were deleted.

自删除表以来,数据库尚未被压缩。The database has not been compacted since the tables were deleted.

使用 Access 用户界面删除了表。The tables were deleted by using the Access user interface.

表不包含任何多值字段或附件字段。The table does not contain any multivalue or Attachment fields.

请将以下过程粘贴到标准模块中。Paste the following procedure into a standard module.

Sub RecoverDeletedTable()

On Error GoTo ExitHere

Dim db As DAO.Database

Dim strTableName As String

Dim strSQL As String

Dim intCount As Integer

Dim blnRestored As Boolean

Set db = CurrentDb()

For intCount = 0 To db.TableDefs.Count - 1

strTableName = db.TableDefs(intCount).Name

If Left(strTableName, 4) = "~tmp" Then

strSQL = "SELECT DISTINCTROW [" & strTableName & "].* INTO " & Mid(strTableName, 5) & " FROM [" & strTableName & "];"

DoCmd.SetWarnings False

DoCmd.RunSQL strSQL

MsgBox "A deleted table has been restored, using the name '" & Mid(strTableName, 5) & "'", vbOKOnly, "Restored"

blnRestored = True

End If

Next intCount

If blnRestored = False Then

MsgBox "No recoverable tables found", vbOKOnly

End If

'*EXIT/ERROR*

ExitHere:

DoCmd.SetWarnings True

Set db = Nothing

Exit Sub

ErrorHandler:

MsgBox Err.Description

Resume ExitHere

End Sub

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值