What is an easy way to list the foreign key contraints in an MDB?

前端 未结 3 1752
遥遥无期
遥遥无期 2021-01-20 22:26

What is an easy way to list the foreign key contraints in an MDB?

Is there a system table that can be queried in order to list this information?

Specifically

相关标签:
3条回答
  • 2021-01-20 23:03
    Dim rs As ADODB.Recordset
    Set rs = oConn.OpenSchema(adSchemaForeignKeys)
    

    where oConn is ADODB.connection

    0 讨论(0)
  • 2021-01-20 23:05

    Or you can examine the relationships collection of the database object:

      Public Sub PrintRelationships()
        Dim varItem As Variant
        Dim varItem2 As Variant
    
        For Each varItem In CurrentDb.Relations
          Debug.Print varItem.Name
          Debug.Print " " & varItem.Table
          Debug.Print " " & varItem.ForeignTable
          For Each varItem2 In varItem.Fields
            Debug.Print ": " & varItem2.Name
          Next varItem2
        Next varItem
      End Sub
    

    There are other properties that might be of interest. Also, an MS Knowledge Base article on copying relationships may give you some ideas.

    0 讨论(0)
  • 2021-01-20 23:16

    Take a look at the results of select * from MSysRelationships.

    0 讨论(0)
提交回复
热议问题