Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL ADD CONSTRAINT ERROR
    text
    copied!<p>I am getting errors for my add constraints. </p> <p>I am using MYSQL workbench to create the tables</p> <p>Message Error from MYSQL workbench: Error Code: 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 'ADD CONSTRAINT <code>user_contact_ibfk1</code> FOREIGN KEY(<code>user_id</code>) REFERENCES `user_ac' at line 1</p> <p>Could this just be a version problem I'm having. I'm using 5.2.4.7</p> <p>Error:</p> <blockquote> <p>22:47:35 ADD CONSTRAINT <code>user_contact_ibfk_1</code> FOREIGN KEY (<code>user_id</code>) REFERENCES <code>user_account</code> (<code>user_id</code>) ON DELETE CASCADE ON UPDATE CASCADE Error Code: 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 'ADD CONSTRAINT <code>user_contact_ibfk_1</code> FOREIGN KEY (<code>user_id</code>) REFERENCES `user_ac' at line 1 0.000 sec</p> </blockquote> <pre><code>-- -- Table structure for table `user_contact` -- CREATE TABLE IF NOT EXISTS `user_contact` ( `contact_id` bigint(11) NOT NULL AUTO_INCREMENT, `user_id` bigint(11) NOT NULL, `first_name` varchar(25) NOT NULL, `last_name` varchar(25) NOT NULL, `email` varchar(50) NOT NULL, `email_code` varchar(32) NOT NULL, `cellnumber` decimal(32,0) NOT NULL, `city` varchar(25) NOT NULL, `state` varchar(25) NOT NULL, `country` varchar(25) NOT NULL, `username` varchar(50) NOT NULL, PRIMARY KEY (`contact_id`), UNIQUE KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ; -- -------------------------------------------------------- -- -- Table structure for table `user_profile` -- CREATE TABLE IF NOT EXISTS `user_profile` ( `profile_id` bigint(11) NOT NULL AUTO_INCREMENT, `user_id` bigint(11) NOT NULL, `username` varchar(50) NOT NULL, `about_me` text NOT NULL, `work_info` varchar(255) NOT NULL, `education_info` varchar(255) NOT NULL, `rating` float NOT NULL, `user_image` varchar(1024) NOT NULL, `friend_array` text NOT NULL, `online_status` tinyint(1) NOT NULL, PRIMARY KEY (`profile_id`), UNIQUE KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; -- -- Table structure for table `user_account` -- CREATE TABLE IF NOT EXISTS `user_account` ( `user_id` bigint(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) NOT NULL, `password` varchar(50) NOT NULL, `active` tinyint(1) NOT NULL DEFAULT '1', `type` int(11) NOT NULL, `online_status` tinyint(1) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=16 ; -- -- Constraints for table `user_contact` -- ALTER TABLE `user_contact` ADD CONSTRAINT `user_contact_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user_account` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; -- -- Constraints for table `user_profile` -- ALTER TABLE `user_profile` ADD CONSTRAINT `user_profile_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user_account` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload