Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个与另一个表有外键关系的表。
我想检查是否存在这种关系,将其删除。
如何编写此查询。
谢谢。
如果您使用的是 SQL Server,这应该可以
if exists (select 1 from sys.objects where object_id = OBJECT_ID(N'[FKName]') AND parent_object_id = OBJECT_ID('TableName')) alter table TableName drop constraint FKName