如何使用SQL在MS Access中'DROP'和未命名的关系/约束? [英] How do I 'DROP' and unamed relationship/constraint in MS Access with SQL?

查看:362
本文介绍了如何使用SQL在MS Access中'DROP'和未命名的关系/约束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Microsoft Access数据库,我有两个表。 Table1具有主键,Table2具有引用Table1主键的外键。此关系在MS Access中的关系查看器中设置和查看,强制引用完整性复选框处于选中状态,并且联接类型是内部联接。关系是:



[Table1] - 1 --------- N - [Table2]



我需要能够通过SQLDROP这种关系/约束。我如何做到这一点?我没有这个关系/约束的名称,因为它在Access中手动设置,而不是使用SQL。是否有办法做我需要做的?

解决方案

使用

确定关系

b> b b> b bb bb bb b / blockquote>

THEN



使用ALTER TABLE命令。



I have a Microsoft Access database and I have two tables. Table1 has a primary key and Table2 has a foreign key that references Table1's primary key. This relationship is set up and viewable in the Relationship viewer in MS Access, the 'Enforce Referential Integrity' check box is checked, and the Join type is an inner join. The relationship is:

[Table1]--1---------N--[Table2]

I need to be able to 'DROP' this relationship/constraint via SQL. How do I do this? I have no name for this relationship/constraint as it was set up in Access manually, not with SQL. Is there a way to do what I need to do?

解决方案

Determine the relationship using

SELECT szRelationship FROM Msysrelationships WHERE szObject = 'childtablename' and szReferencedObject = 'parenttablename'

THEN

Use the ALTER TABLE command. Something along the line of this

ALTER TABLE Table2 DROP CONSTRAINT Relation1

这篇关于如何使用SQL在MS Access中'DROP'和未命名的关系/约束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆