Does anyone know how to fix Error 1103 in MySQL? - mysql

I am quite new to MySQL, I downloaded the file and then opened it in SQL I ran it, but it didn't work and stated the following
Error Code: 1103. Incorrect table name 'campaign';/!40101 SET #saved_cs_client = ##character_set_client /;/!40101 SET character_set'
This is where I believe the problem is
DROP TABLE IF EXISTS `campaign';
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `campaign` (
`id` bigint(20) NOT NULL,
`name` text,
`sub_category_id` bigint(20) DEFAULT NULL,
`country_id` bigint(20) DEFAULT NULL,
`currency_id` bigint(20) DEFAULT NULL,
`launched` datetime DEFAULT NULL,
`deadline` datetime DEFAULT NULL,
`goal` double DEFAULT NULL,
`pledged` double DEFAULT NULL,
`backers` bigint(20) DEFAULT NULL,
`outcome` text,
PRIMARY KEY (`id`),
KEY `country_id` (`country_id`),
KEY `sub_category_id` (`sub_category_id`),
KEY `currency_id` (`currency_id`),
CONSTRAINT `campaign_ibfk_1` FOREIGN KEY (`country_id`) REFERENCES `country` (`id`),
CONSTRAINT `campaign_ibfk_2` FOREIGN KEY (`sub_category_id`) REFERENCES `sub_category` (`id`),
CONSTRAINT `campaign_ibfk_3` FOREIGN KEY (`currency_id`) REFERENCES `currency` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
Dumping data for table `campaign`
--
LOCK TABLES `campaign` WRITE;
/*!40000 ALTER TABLE `campaign` DISABLE KEYS */;
INSERT INTO `campaign` VALUES (1,'Ragdolls',23,2,2)
INSERT INTO `campaign` VALUES (8667,'Blank Screen Films Summer Project 2013')
/*!40000 ALTER TABLE `campaign` ENABLE KEYS */;
UNLOCK TABLES;
Feel free to ask any question to attain more insight.

Where you have:
DROP TABLE IF EXISTS `campaign';
this is supposed to be:
DROP TABLE IF EXISTS `campaign`;
Either you accidentally changed the backtick to a single quote, or something in your "downloaded the file and then opened it in SQL" changed it on you.

Related

MySQL dump file has some issue with foreign key constraint. referenced column '**' in foreign key constraint '**' are incompatible

I would like to import SQL dump file, some how it's not working.
I got this error when I try to import data.
Referencing column 'originator_id' and referenced column 'name' in foreign key constraint 'fk_rails_79d8c4ccda' are incompatible.
DROP TABLE IF EXISTS `loan_fee_shares`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `loan_fee_shares` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`originator_id` varchar(255) DEFAULT NULL,
`percent` decimal(6,2) DEFAULT NULL COMMENT 'belongs to [0,1] set',
`active` tinyint(1) DEFAULT '0',
`deactivated_at` timestamp NULL DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `fk_rails_79d8c4ccda` (`originator_id`),
CONSTRAINT `fk_rails_79d8c4ccda` FOREIGN KEY (`originator_id`) REFERENCES `originators` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
DROP TABLE IF EXISTS `originators`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `originators` (
`name` varchar(255) DEFAULT NULL,
`description` varchar(100) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`name`),
UNIQUE KEY `index_originators_on_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
I am posting this for someone who might have the same issue in the future.
Barmar has a good point. and I moved originators table to before loan_fee_shares. But I still had an issue.
and It had an issue with DEFAULT CHARSET=latin1, I had to change it to DEFAULT CHARSET=utf8. and It works.
I suggest that change all your tables to the same character set.
How to change all the tables in my database to UTF8 character set?

Problem with importing mysql workbench data

I have a table and data. When importing, automatically importing data into the user table throws a foreign key error. How do I load data into a table?
I understand that the problem is in the foreign key and the difference in id and name, but how to import the data?
need to write some kind of request?
This is the csv of the loaded data
Administrator,j.doe#amonic.com,123,John,Doe,Abu dhabi,1/13/1983,1
User,k.omar#amonic.com,4258,Karim,Omar,Abu dhabi,3/19/1980,1
User,h.saeed#amonic.com,2020,Hannan,Saeed,Cairo,12/20/1989,1
User,a.hobart#amonic.com,6996,Andrew,Hobart,Riyadh,1/30/1990,1
User,k.anderson#amonic.com,4570,Katrin,Anderson,Doha,11/10/1992,1
User,h.wyrick#amonic.com,1199,Hava,Wyrick,Abu dhabi,8/8/1988,1
User,marie.horn#amonic.com,55555,Marie,Horn,Bahrain,4/6/1981,1
User,m.osteen#amonic.com,9800,Milagros,Osteen,Abu dhabi,2/3/1991,0
and this is the mysql code
-- Dumping data for table `countries`
--
LOCK TABLES `countries` WRITE;
/*!40000 ALTER TABLE `countries` DISABLE KEYS */;
INSERT INTO `countries` VALUES (1,'Afghanistan'),(2,'Albania'),(3,'Algeria'),(4,'Andorra'),(5,'Angola'),(6,'Antigua & Deps'),(7,'Argentina'),(8,'Armenia'),(9,'Australia'),(10,'Austria'),(11,'Azerbaijan'),(12,'Bahamas'),(13,'Bahrain'),(14,'Bangladesh'),(15,'Barbados'),(16,'Belarus'),(17,'Belgium'),(18,'Belize'),(19,'Benin'),(20,'Bhutan'),(21,'Bolivia'),(22,'Bosnia Herzegovina'),(23,'Botswana'),(24,'Brazil'),(25,'Brunei'),(26,'Bulgaria'),(27,'Burkina'),(28,'Burundi'),(29,'Cambodia'),(30,'Cameroon'),(31,'Canada'),(32,'Cape Verde'),(33,'Central African Rep'),(34,'Chad'),(35,'Chile'),(36,'China'),(37,'Colombia'),(38,'Comoros'),(39,'Congo'),(40,'Congo {Democratic Rep}'),(41,'Costa Rica'),(42,'Croatia'),(43,'Cuba'),(44,'Cyprus'),(45,'Czech Republic'),(46,'Denmark'),(47,'Djibouti'),(48,'Dominica'),(49,'Dominican Republic'),(50,'East Timor'),(51,'Ecuador'),(52,'Egypt'),(53,'El Salvador'),(54,'Equatorial Guinea'),(55,'Eritrea'),(56,'Estonia'),(57,'Ethiopia'),(58,'Fiji'),(59,'Finland'),(60,'France'),(61,'Gabon'),(62,'Gambia'),(63,'Georgia'),(64,'Germany'),(65,'Ghana'),(66,'Greece'),(67,'Grenada'),(68,'Guatemala'),(69,'Guinea'),(70,'Guinea-Bissau'),(71,'Guyana'),(72,'Haiti'),(73,'Honduras'),(74,'Hungary'),(75,'Iceland'),(76,'India'),(77,'Indonesia'),(78,'Iran'),(79,'Iraq'),(80,'Ireland {Republic}'),(81,'Israel'),(82,'Italy'),(83,'Ivory Coast'),(84,'Jamaica'),(85,'Japan'),(86,'Jordan'),(87,'Kazakhstan'),(88,'Kenya'),(89,'Kiribati'),(90,'Korea North'),(91,'Korea South'),(92,'Kosovo'),(93,'Kuwait'),(94,'Kyrgyzstan'),(95,'Laos'),(96,'Latvia'),(97,'Lebanon'),(98,'Lesotho'),(99,'Liberia'),(100,'Libya'),(101,'Liechtenstein'),(102,'Lithuania'),(103,'Luxembourg'),(104,'Macedonia'),(105,'Madagascar'),(106,'Malawi'),(107,'Malaysia'),(108,'Maldives'),(109,'Mali'),(110,'Malta'),(111,'Marshall Islands'),(112,'Mauritania'),(113,'Mauritius'),(114,'Mexico'),(115,'Micronesia'),(116,'Moldova'),(117,'Monaco'),(118,'Mongolia'),(119,'Montenegro'),(120,'Morocco'),(121,'Mozambique'),(122,'Myanmar, {Burma}'),(123,'Namibia'),(124,'Nauru'),(125,'Nepal'),(126,'Netherlands'),(127,'New Zealand'),(128,'Nicaragua'),(129,'Niger'),(130,'Nigeria'),(131,'Norway'),(132,'Oman'),(133,'Pakistan'),(134,'Palau'),(135,'Panama'),(136,'Papua New Guinea'),(137,'Paraguay'),(138,'Peru'),(139,'Philippines'),(140,'Poland'),(141,'Portugal'),(142,'Qatar'),(143,'Romania'),(144,'Russian Federation'),(145,'Rwanda'),(146,'St Kitts & Nevis'),(147,'St Lucia'),(148,'Saint Vincent & the Grenadines'),(149,'Samoa'),(150,'San Marino'),(151,'Sao Tome & Principe'),(152,'Saudi Arabia'),(153,'Senegal'),(154,'Serbia'),(155,'Seychelles'),(156,'Sierra Leone'),(157,'Singapore'),(158,'Slovakia'),(159,'Slovenia'),(160,'Solomon Islands'),(161,'Somalia'),(162,'South Africa'),(163,'South Sudan'),(164,'Spain'),(165,'Sri Lanka'),(166,'Sudan'),(167,'Suriname'),(168,'Swaziland'),(169,'Sweden'),(170,'Switzerland'),(171,'Syria'),(172,'Taiwan'),(173,'Tajikistan'),(174,'Tanzania'),(175,'Thailand'),(176,'Togo'),(177,'Tonga'),(178,'Trinidad & Tobago'),(179,'Tunisia'),(180,'Turkey'),(181,'Turkmenistan'),(182,'Tuvalu'),(183,'Uganda'),(184,'Ukraine'),(185,'United Arab Emirates'),(186,'United Kingdom'),(187,'United States'),(188,'Uruguay'),(189,'Uzbekistan'),(190,'Vanuatu'),(191,'Vatican City'),(192,'Venezuela'),(193,'Vietnam'),(194,'Yemen'),(195,'Zambia'),(196,'Zimbabwe');
/*!40000 ALTER TABLE `countries` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `offices`
--
DROP TABLE IF EXISTS `offices`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `offices` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`CountryID` int(11) NOT NULL,
`Title` varchar(50) COLLATE utf8_bin NOT NULL,
`Phone` varchar(50) COLLATE utf8_bin NOT NULL,
`Contact` varchar(250) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ID`),
KEY `FK_Office_Country` (`CountryID`),
CONSTRAINT `FK_Office_Country` FOREIGN KEY (`CountryID`) REFERENCES `countries` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `offices`
--
LOCK TABLES `offices` WRITE;
/*!40000 ALTER TABLE `offices` DISABLE KEYS */;
INSERT INTO `offices` VALUES (1,185,'Abu dhabi','638-757-8582\r\n','MIchael Malki'),(3,52,'Cairo','252-224-8525','David Johns'),(4,13,'Bahrain','542-227-5825','Katie Ballmer'),(5,142,'Doha','758-278-9597','Ariel Levy'),(6,152,'Riyadh','285-285-1474','Andrew Hobart');
/*!40000 ALTER TABLE `offices` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `roles`
--
DROP TABLE IF EXISTS `roles`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `roles` (
`ID` int(11) NOT NULL,
`Title` varchar(50) COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `roles`
--
LOCK TABLES `roles` WRITE;
/*!40000 ALTER TABLE `roles` DISABLE KEYS */;
INSERT INTO `roles` VALUES (1,'Administrator'),(2,'User');
/*!40000 ALTER TABLE `roles` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `users` (
`ID` int(11) NOT NULL,
`RoleID` int(11) NOT NULL,
`Email` varchar(150) COLLATE utf8_bin NOT NULL,
`Password` varchar(50) COLLATE utf8_bin NOT NULL,
`FirstName` varchar(50) COLLATE utf8_bin DEFAULT NULL,
`LastName` varchar(50) COLLATE utf8_bin NOT NULL,
`OfficeID` int(11) DEFAULT NULL,
`Birthdate` date DEFAULT NULL,
`Active` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`ID`),
KEY `FK_Users_Offices` (`OfficeID`),
KEY `FK_Users_Roles` (`RoleID`),
CONSTRAINT `FK_Users_Offices` FOREIGN KEY (`OfficeID`) REFERENCES `offices` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_Users_Roles` FOREIGN KEY (`RoleID`) REFERENCES `roles` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `users`
--

Cannot add foreign key constraint in mysql-workbench

The following sql script causes the Error Code: 1215. Cannot add foreign key constraint in MySQL Workbench
DROP TABLE IF EXISTS `bookings`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `bookings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`van_id` int(11) NOT NULL,
`driver_id` int(11) NOT NULL,
`route_id` int(11) NOT NULL,
`registered_seats` int(11) NOT NULL,
`departure_time` varchar(11) NOT NULL,
`arival_time` varchar(11) NOT NULL,
`departure_date` varchar(11) NOT NULL,
`total_cost` int(11) NOT NULL,
`expected_price` int(11) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY (`van_id`) REFERENCES `van` (`id`) ON DELETE SET NULL,
FOREIGN KEY (`driver_id`) REFERENCES `driver` (`id`) ON DELETE SET NULL,
FOREIGN KEY (`route_id`) REFERENCES `route` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
For reference, below are the scripts of the related tables, all of these work fine.
For table van,
DROP TABLE IF EXISTS `van`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `van` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`vehicle_registration` varchar(45) NOT NULL UNIQUE,
`vehicle_type` varchar(45) NOT NULL,
`total_seats` int(11) NOT NULL,
`category` varchar(45) NOT NULL,
`flagged` int(2) DEFAULT 0 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
For table Driver,
DROP TABLE IF EXISTS `driver`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `driver` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(45) NOT NULL ,
`last_name` varchar(45) DEFAULT NULL,
`cnic` varchar(45) NOT NULL UNIQUE,
`license_number` varchar(11) NOT NULL UNIQUE,
`phonenumber` int(11) NOT NULL unique,
`picture` varchar(15) NOT NULL unique,
`flagged` int(2) DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
For table route,
DROP TABLE IF EXISTS `route`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `route` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`source` varchar(45) NOT NULL,
`destination` varchar(45) NOT NULL,
`exp_t_time` varchar(45) NOT NULL,
`eco_fare` int(11) NOT NULL,
`ac_fare` int(11) NOT NULL,
`state` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
I was trying to SET NULL an attribute (in the foreign key constraint) that is supposed to be NOT NULL.
I made the following changes in the bookings mysql script.
Before:
FOREIGN KEY (`van_id`) REFERENCES `van` (`id`) ON DELETE SET NULL,
FOREIGN KEY (`driver_id`) REFERENCES `driver` (`id`) ON DELETE SET NULL,
FOREIGN KEY (`route_id`) REFERENCES `route` (`id`) ON DELETE SET NULL
After:
FOREIGN KEY (`van_id`) REFERENCES `van` (`id`) ON DELETE CASCADE,
FOREIGN KEY (`driver_id`) REFERENCES `driver` (`id`) ON DELETE CASCADE,
FOREIGN KEY (`route_id`) REFERENCES `route` (`id`) ON DELETE CASCADE

MySQL #1100 - Table 'USER' was not locked with LOCK TABLES

I am having a very strange problem. I have developed a database and it works perfectly on my local server however then I tried to put it online on my server I keep getting MySQL error:
#1100 - Table 'USER' was not locked with LOCK TABLES
(This is then I try to import my .sql file via phpMyAdmin)
Once again this same script gives no errors on my local server (WAMP server)
I have no Idea why it does not work then I try to put it online. Also it creates the tables and structure the problem is only with the insert statements.
SQL script:
/*!40101 SET NAMES utf8 */;
/*!40101 SET SQL_MODE=''*/;
/*!40014 SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET #OLD_SQL_NOTES=##SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`a3823833_MiniPos` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `a3823833_MiniPos`;
/*Table structure for table `user` */
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`userid` int(4) NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`email` varchar(50) NOT NULL,
PRIMARY KEY (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Table structure for table `profile` */
DROP TABLE IF EXISTS `profile`;
CREATE TABLE `profile` (
`userid` int(4) NOT NULL,
`lastName` varchar(50),
`firstName` varchar(50),
`dob` varchar(10),
PRIMARY KEY (`userid`),
CONSTRAINT `profile_fk` FOREIGN KEY (`userid`) REFERENCES `user` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Table structure for table 'topic'*/
DROP TABLE IF EXISTS `topic`;
CREATE TABLE `topic` (
`topicid` int(4) NOT NULL auto_increment,
`userid` int(4) NOT NULL,
`text` varchar(2000),
`time` datetime,
PRIMARY KEY (`topicid`),
CONSTRAINT `userid_fk` FOREIGN KEY (`userid`) REFERENCES `user` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/* Table structure for table 'post'*/
DROP TABLE IF EXISTS `post`;
CREATE TABLE `post` (
`postid` int(4) NOT NULL auto_increment,
`topicid` int(4),
`userid` int(4) NOT NULL,
`text` varchar(2000),
`time` datetime,
PRIMARY KEY (`postid`),
CONSTRAINT `post_userid_fk` FOREIGN KEY (`userid`) REFERENCES `user` (`userid`),
CONSTRAINT `post_topicid_fk` FOREIGN KEY (`topicid`) REFERENCES `topic` (`topicid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
LOCK TABLES `user` WRITE;
INSERT INTO USER VALUES (1,'Martynas','MartynPass','Martyn#email.com'),(2,'Syed','SyedPass','Syed#email.com'),(3,'Stephanie','StephPass','Steph#email.com');
UNLOCK TABLES;
LOCK TABLES `topic` WRITE;
INSERT INTO topic VALUES (1, 1,'Topic Number 1','2015-06-11 20:15:00'),(2, 2,'Topic Number 2','2015-06-10 19:15:00'),(3, 3,'Topic Number 3','2015-06-09 18:15:00');
UNLOCK TABLES;
LOCK TABLES `post` WRITE;
INSERT INTO post VALUES (1, 1, 1, 'Very Interesting Topic Number 1','2015-06-11 20:15:00'),(2, 1, 2, 'Agree!','2015-06-11 21:15:00');
UNLOCK TABLES;

Cannot Create Table after Lowercased all text in MySQL Dump file

I'm having an error restoring tables which have Foreign Keys after lowercasing the contents of a mysql dump file.
My goal is to lowercase all structure in a mysql database.
I used vim to lowercase all contents of a mysqldump file when trying to restore the database, this is the error I get.
$ mysql -u [user] -p[password] dme < mysqldump.sql
ERROR 1005 (HY000) at line 399: Can't create table 'dme.contacts' (errno: 121)
The restore is error'ing out on any table which has Foreign Key contstraints. If I remove lines after the Primary Key for each table, the entire restore works fine.
My question is, what is causing this and how can I keep my Foreign Keys in the process?
Lowercased.sql example which results in the error (fyi prior to dme.contacts there are multiple tables which are created just fine. Only tables w/ Foreign Keys and Contstraints have issues.)
drop table if exists `contacts`;
/*!40101 set #saved_cs_client = ##character_set_client */;
/*!40101 set character_set_client = utf8 */;
create table `contacts` (
`contactid` int(11) not null auto_increment,
`firstname` varchar(100) default null,
`lastname` varchar(100) not null,
`fullname` varchar(200) not null,
`dob` datetime default null,
`sex` char(1) default null,
`voided` datetime default null,
`vendorid` int(11) not null,
`contacttypeid` int(11) default null,
`comments` varchar(1500) default null,
primary key (`contactid`),
key `fk_contacts_vendors` (`vendorid`),
key `fk_contacts_contacttype` (`contacttypeid`),
constraint `fk_contacts_contacttype` foreign key (`contacttypeid`) references `contacttype` (`contacttypeid`) on delete no action on update no action,
constraint `fk_contacts_vendors` foreign key (`vendorid`) references `vendors` (`vendorid`) on delete no action on update no action
) engine=innodb default charset=utf8;
/*!40101 set character_set_client = #saved_cs_client */;
--
-- dumping data for table `contacts`
--
lock tables `contacts` write;
/*!40000 alter table `contacts` disable keys */;
/*!40000 alter table `contacts` enable keys */;
unlock tables;
Original from the mysqldump.sql (No Error)
--
-- Table structure for table `Contacts`
--
DROP TABLE IF EXISTS `Contacts`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `Contacts` (
`ContactId` int(11) NOT NULL AUTO_INCREMENT,
`FirstName` varchar(100) DEFAULT NULL,
`LastName` varchar(100) NOT NULL,
`FullName` varchar(200) NOT NULL,
`DOB` datetime DEFAULT NULL,
`Sex` char(1) DEFAULT NULL,
`Voided` datetime DEFAULT NULL,
`VendorID` int(11) NOT NULL,
`ContactTypeID` int(11) DEFAULT NULL,
`Comments` varchar(1500) DEFAULT NULL,
PRIMARY KEY (`ContactId`),
KEY `FK_Contacts_Vendors` (`VendorID`),
KEY `FK_Contacts_ContactType` (`ContactTypeID`),
CONSTRAINT `FK_Contacts_ContactType` FOREIGN KEY (`ContactTypeID`) REFERENCES `ContactType` (`ContactTYpeID`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_Contacts_Vendors` FOREIGN KEY (`VendorID`) REFERENCES `Vendors` (`VendorId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Dumping data for table `Contacts`
--
LOCK TABLES `Contacts` WRITE;
/*!40000 ALTER TABLE `Contacts` DISABLE KEYS */;
/*!40000 ALTER TABLE `Contacts` ENABLE KEYS */;
UNLOCK TABLES;
Try removing the constrain name. Sample:
constraint `fk_contacts_contacttype` foreign key (`contacttypeid`) ....
To
constraint foreign key (`contacttypeid`) ...