0
我試圖確保何時mysqldump數據庫的約束是按照數字順序執行下面的查詢後。當我做一個沒有AFTER的轉儲(不起作用)時,它顯示phppos_sales_ibfk_3作爲第一個約束。mysql添加約束(ALTER)如何將它們按順序
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
*爲什麼*約束的定義順序對您來說很重要? – eggyal
這只是在我導出數據庫時保持組織有序。我知道這並不重要(如果有的話),但我很好奇 –
我懷疑你將不得不吞下你的強迫症在這一個:) – eggyal