-1

I try to fix some error in Jira as mention in this page but when I try to run an SQL query, I got the below error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT fk_ao_8542f1_ifj_obj_attr_val_object_attribute_id' at line 1

My Query is:

ALTER TABLE AO_8542F1_IFJ_OBJ_ATTR_VAL 
DROP CONSTRAINT `fk_ao_8542f1_ifj_obj_attr_val_object_attribute_id`

How I can fix this Query? I use MySQL version 5.7

Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
Arman Feyzi
  • 788
  • 2
  • 11
  • 28

2 Answers2

1

Drop MySQL foreign key constraints To drop a foreign key constraint, you use the ALTER TABLE statement:

ALTER TABLE table_name 
DROP FOREIGN KEY constraint_name;
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
0

Judging by the name of the constraint, I believe it's a foreign key and MySQL has a different approach to drop foreign keys:

ALTER TABLE AO_8542F1_IFJ_OBJ_ATTR_VAL
DROP FOREIGN KEY `fk_ao_8542f1_ifj_obj_attr_val_object_attribute_id`
osumatu
  • 410
  • 1
  • 8
  • 25