Adding foreign key to existing table gives error 1050 table already exists

后端 未结 9 1158
栀梦
栀梦 2021-01-07 18:11

I\'ve a table CustomizationSet with the columns:

customization_set_guid (which is a non-nullable guid and also the primary key)
creator_account_guid
and a fe         


        
9条回答
  •  萌比男神i
    2021-01-07 18:42

    I got the same error, and it was due to the fact that the foreign key already existed. What you want is just to add the constraint:

    ALTER TABLE Registration 
      ADD CONSTRAINT idx_Registration_CustomizationSet 
      FOREIGN KEY (customization_set_guid) 
      REFERENCES CustomizationSet(customization_set_guid);
    

提交回复
热议问题