如果我知道表存在但我不知道外键约束是否存在,那么我可以这样做:
ALTER TABLE table_name DROP CONSTRAINT IF EXISTS constraint_name
如果我不知道表本身是否存在怎么办?我想要一个具有如下结果的语句:
if (the table does not exist)
{
nothing happens
}
else if (the table exists, but the foreign key constraint does not exist)
{
nothing happens
}
else
{
the foreign key constraint is dropped, but the table continues to exist
}