我正在尝试确保在执行以下查询后mysqldump数据库时约束是按数字顺序。当我在没有AFTER的情况下进行转储(这不起作用)时,它会将phppos_sales_ibfk_3显示为第一个约束。
ALTER TABLE `phppos_sales`
ADD CONSTRAINT `phppos_sales_ibfk_3` FOREIGN KEY (`location_id`) REFERENCES `phppos_locations` (`location_id`);
ADD CONSTRAINT `phppos_sales_ibfk_1` FOREIGN KEY (`employee_id`) REFERENCES `phppos_employees` (`person_id`),
ADD CONSTRAINT `phppos_sales_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `phppos_customers` (`person_id`),
我正在努力改变phppos_sales
ALTER TABLE `phppos_sales`
ADD CONSTRAINT `phppos_sales_ibfk_3` AFTER `phppos_sales_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `phppos_locations` (`location_id`);
我收到错误:
#1064 - 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 'AFTER `phppos_sales_ibfk_2` FOREIGN KEY (`location_id`) REFERENCES `phppos_locat' at line 6
答案 0 :(得分:0)
“ALTER TABLE”的“ADD CONSTRAINT”部分不允许使用关键字“AFTER”。
您可以控制列在表格中的显示位置,但无法控制约束的显示位置。