【问题标题】:Listing Cascade Update / Delete Referential Integrity Rules in an MS-Access Database?列出 MS-Access 数据库中的级联更新/删除参照完整性规则?
【发布时间】:2012-10-12 09:59:00
【问题描述】:

在 MS-Access 中,我知道参照完整性规则,例如级联更新和删除以及使用 DDL 创建它们。

但是表已经创建了,怎么再列出来呢?

【问题讨论】:

    标签: sql vba ms-access ms-access-2003 referential-integrity


    【解决方案1】:

    在 VBA 中,您可以使用 TableDefs 和关系集合来显示表和关系属性。您还可以使用 ADO 架构来获取信息。

    特别是,您会希望引用关系的属性:

    Name                    Value       Description
    dbRelationDeleteCascade 4096        Deletions cascade
    dbRelationDontEnforce   2           Relationship not enforced (no referential integrity)
    dbRelationInherited     4           Relationship exists in the database containing the two linked tables
    dbRelationLeft          16777216    Microsoft Access only. In Design view, display a LEFT JOIN as the default join type.
    dbRelationRight         33554432    Microsoft Access only. In Design view, display a RIGHT JOIN as the default join type.
    dbRelationUnique        1           One-to-one relationship
    dbRelationUpdateCascade 256         Updates cascade
    

    http://msdn.microsoft.com/en-us/library/bb225809.aspx

    Dim rel As Relation
    Dim tdf As TableDef
    
    For Each rel In CurrentDb.Relations
        Debug.Print rel.Attributes
    Next
    

    4352 = dbRelationUpdateCascade + dbRelationDeleteCascade

    【讨论】:

      猜你喜欢
      • 2016-05-31
      • 1970-01-01
      • 2011-03-24
      • 1970-01-01
      • 2017-06-13
      • 2012-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多