2

我想比较两个 Access 数据库并检查其中是否有任何字段或类型不匹配。

有什么方法可以检查使用数据集还是有更快的方法来做到这一点?

谢谢。

4

6 回答 6

3

您可以使用 StarInix Software 的 Free Database Compare 2.0(评论)进行比较。

于 2009-03-27T18:26:37.250 回答
3
  1. 使用 Access 数据库 Documenter (Tools\Analyze\Documenter) 创建数据库对象的报告。
  2. 将此报告导出为文本文件(在报告中单击鼠标右键,导出...,另存为文本文件类型)。

对每个数据库执行此操作,并使用您选择的差异工具比较文本文件。

于 2009-08-12T18:02:27.107 回答
1

我一直在 Access Pro Table Compare。我在网上找到了它,它非常适合比较 MS Access 表、查找字段和数据类型问题等。

Access Pro 表比较工具

于 2011-04-07T14:24:22.567 回答
0

我制作了一个允许比较 Access 对象和数据的AccdbMerge实用程序。在模式比较范围内 - 它允许比较表和查询列表以及每个表/查询定义。

于 2012-11-13T22:37:22.517 回答
0

您可以像在 SQL Server 数据库中一样读取 access 数据库中的系统表(默认情况下是隐藏的),但使用 ODBC 驱动程序。

于 2009-03-27T08:38:28.100 回答
-1
Option Compare Database

Private Sub Command14_Click()

Dim tablename1, tablename2, field_date As String
tablename1 = Text10.Value
tablename2 = Text13.Value
flter_date = Text16.Value
length = Len(tablename1) - Len("gahpu00d_")
field_date = Right(tablename1, length) & "_posted_dt"

'On Error GoTo Err_cmdValidateGeneralInfo_Click

 Dim F As DAO.Field
 Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Set curDB = CurrentDb()

DoCmd.CopyObject , "Unmatched_records", acTable, tablename1
curDB.Execute "DELETE FROM Unmatched_records"


 'to calculate count of filtered data in staged

strsql = "Select * from " & tablename1 & " where cdate(" & field_date & ") = """ & flter_date & """ order by " & field_date & ""
DoCmd.RunSQL "Select * into filter_data1 from " & tablename1 & " where cdate(" & field_date & ") = """ & flter_date & """"
count_data1 = DCount(field_date, "filter_data1")
Text18.Enabled = True
Text18.Value = count_data1

'to calculate count of filtered data in production

strsql1 = "Select * from " & tablename2 & " where cdate(" & field_date & ") = """ & flter_date & """ order by " & field_date & ""
DoCmd.RunSQL "Select * into filter_data2 from " & tablename2 & " where cdate(" & field_date & ") = """ & flter_date & """"
count_data2 = DCount(field_date, "filter_data2")
Text20.Enabled = True
Text20.Value = count_data2

If count_data1 <> count_data2 Then
If count_data1 > count_data2 Then
  MsgBox "The number of records in the table didnt match." & tablename1 & " has more records than " & tablename2
  Exit Sub

  Else
  MsgBox "The number of records in the table didnt match." & tablename2 & " has more records than " & tablename1
  Exit Sub

End If
End If

Set rs = curDB.OpenRecordset(strsql)
Set rs1 = curDB.OpenRecordset(strsql1)


    Do Until rs.EOF
      For Each F In rs.Fields


        If rs.Fields(F.Name) <> rs1.Fields(F.Name) Then
          'rs.Edit
          strsql = "Select * into test from " & tablename1 & " where " & F.Name & " = """ & rs.Fields(F.Name) & """"
          DoCmd.RunSQL strsql

          If DCount(F.Name, "test") <> 0 Then
          GoTo append_unmatch

          'appending unmacthed records
append_unmatch:

          strsql2 = "insert into Unmatched_records Select * from test"
          DoCmd.RunSQL strsql2

          'if record doesnt match move to next one
          GoTo Nextrecord
          End If
         ' rs.Fields(F.Name) = rs1.Fields(F.Name)
         ' rs.Update
        End If
      Next F

Nextrecord:
rs.MoveNext
rs1.MoveNext
    Loop


     'To check whether tables matched or not
final:
    Dim rs2 As DAO.Recordset
    strsql3 = "select * from Unmatched_records"
    Set rs2 = curDB.OpenRecordset(strsql3)
    For Each F In rs2.Fields
    If DCount(F.Name, "Unmatched_records") <> 0 Then
    MsgBox ("The two tables didnt match. Check table Unmatched_records for unmatching reocrds.")
    Else
    MsgBox ("Tables match!")
    End If
Exit Sub
   Next F
    rs2.Close


End Sub

Private Sub Form_Load()
Text20.Enabled = False
Text18.Enabled = False
Text18.Value = ""
Text20.Value = ""
End Sub
于 2013-01-01T21:58:51.660 回答