列出级联更新/删除MS-Access数据库中的参照完整性规则?

时间:2012-10-22 14:52:01

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

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

但是在创建表之后,如何再次列出这些表?

1 个答案:

答案 0 :(得分:1)

在VBA中,您可以使用TableDefs和Relations集合来显示表和关系属性。您还可以使用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