douhan8581 2017-04-24 11:08
浏览 67

创建表时的外键问题

I get an error: "#1005 - Can't create table contacts.contact (errno: 150 "Foreign key constraint is incorrectly formed") (Details…)"

DROP TABLE IF EXISTS `contact`;

CREATE TABLE `contact` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `Contact_Title` varchar(30) DEFAULT NULL,
  `Contact_First` varchar(5) NOT NULL,
  `Contact_Middle` varchar(30) DEFAULT NULL,
  `Contact_Last` varchar(8) NOT NULL,
  `Lead_Referral_Source` varchar(23) NOT NULL,
  `Date_of_Initial_Contact` date NOT NULL,
  `Title` varchar(20) NOT NULL,
  `Company` varchar(16) NOT NULL,
  `Industry` varchar(12) NOT NULL,
  `Address` varchar(38) NOT NULL,
  `Address_Street_1` varchar(17) NOT NULL,
  `Address_Street_2` varchar(30) DEFAULT NULL,
  `Address_City` varchar(12) NOT NULL,
  `Address_State` char(2) NOT NULL DEFAULT '',
  `Address_Zip` int(11) NOT NULL,
  `Address_Country` varchar(30) DEFAULT NULL,
  `Phone` varchar(14) NOT NULL,
  `Email` varchar(20) NOT NULL,
  `Status` int(11) unsigned NOT NULL,
  `Website` varchar(23) NOT NULL,
  `LinkedIn_Profile` varchar(21) NOT NULL,
  `Background_Info` text NOT NULL,
  `Sales_Rep` int(11) unsigned NOT NULL,
  `Rating` decimal(4,2) NOT NULL,
  `Project_Type` varchar(35) DEFAULT NULL,
  `Project_Description` tinytext,
  `Proposal_Due_Date` date DEFAULT NULL,
  `Budget` decimal(10,2) DEFAULT NULL,
  `Deliverables` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `FK_SALES_REP` (`Sales_Rep`),
  KEY `FK_STATUS` (`Status`),
  CONSTRAINT `FK_SALES_REP` FOREIGN KEY (`Sales_Rep`) REFERENCES `users` (`id`),
  CONSTRAINT `FK_STATUS` FOREIGN KEY (`Status`) REFERENCES `contact_status` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

LOCK TABLES `contact` WRITE;
/*!40000 ALTER TABLE `contact` DISABLE KEYS */;

INSERT INTO `contact` (`id`, `Contact_Title`, `Contact_First`, `Contact_Middle`, `Contact_Last`, `Lead_Referral_Source`, `Date_of_Initial_Contact`, `Title`, `Company`, `Industry`, `Address`, `Address_Street_1`, `Address_Street_2`, `Address_City`, `Address_State`, `Address_Zip`, `Address_Country`, `Phone`, `Email`, `Status`, `Website`, `LinkedIn_Profile`, `Background_Info`, `Sales_Rep`, `Rating`, `Project_Type`, `Project_Description`, `Proposal_Due_Date`, `Budget`, `Deliverables`)
VALUES
    (1,NULL,'Amir',NULL,'Kahnzz','www.google .com','2014-05-09','PR Director','Barnes and Wells','PR','52 Broadway New York, NY 12345','52 Broadway',NULL,'New York','NY',12345,NULL,'(234) 432-2234','amir@pr.com',1,'www.pr.com','www.sample.com','4 years as PR Dir. Knows the biz and has wide network.',1,4.00,NULL,NULL,NULL,NULL,NULL),
    (2,NULL,'Dave',NULL,'Myers','Mack Truck Partner Site','2014-02-11','DEF Sales','DEF Fluids','Auto','456 Diesel St Philadelphia, PA 19308','456 Diesel St',NULL,'Philadelphia','PA',19308,NULL,'(765) 765-7755','dave@def.com',2,'www.def.com','www.sample.com','19 years in biz',2,2.50,NULL,NULL,NULL,NULL,NULL),
    (3,NULL,'Jason',NULL,'Wright','salesforce associate','2014-09-12','Marketing Director','Ben and Jerry\'s','Food','123 Ice Cream Way Burlington, VT 12345','123 Ice Cream Way',NULL,'Burlington','VT',12345,NULL,'(123) 432-1223','eat@benandjerrys.com',1,'www.benandjerrys.com','http://www.sample.com','Amazing ice creme company from Vermont. Sustainable practices.',1,4.00,NULL,NULL,NULL,NULL,NULL),
    (4,NULL,'Linda',NULL,'DeCastro','Conference','2014-01-19','Regional Sales Mgr','Pillsbury','Retail Foods','44 Reading Rd Flourtown, NJ 39485','44 Reading Rd',NULL,'Flourtown','NJ',39485,NULL,'(555) 555-5555','linda@pillsbury.com',3,'www.pillsbury.com','www.sample.com','New territory MGR',1,3.00,'New Packaging for Cookie products','Design new cookie packaging for new line of Sugar Free cookies.','2014-11-01',45000.00,'6 Proofs, multiple assets'),
    (5,NULL,'Sally',NULL,'Jane','CES Conference','2014-07-01','COO','Facetech','Tech','123 Tech Blvd Menlo Park, CA 12345','123 Tech Blvd',NULL,'Menlo Park','CA',12345,NULL,'(321) 321-1122','sally@facetech.com',1,'http://www.facetech.com','www.sample.com','Great contact, has a really great roadmap.',1,5.00,NULL,NULL,NULL,30000.00,NULL),
    (6,NULL,'Tim',NULL,'Smith','www.google.com','2014-10-10','Supply Chain Manager','Levis','Apparel','1 Blue Jean St. Corduroy, CO 12345','1 Blue Jean St.',NULL,'Corduroy','CO',12345,NULL,'(321) 321-4321','tim@levis.com',2,'www.levis.com','www.sample.com','Jeans and apparel for eastern U.S.<br />',1,3.50,'Shelf talkers; kiosk style displays','Set up shelf talkers for stock shelves with an end of aisle kiosk detailing the history of Levis.','2014-11-05',333000.00,'10k shelf talkers, 1500 kiosks');

/*!40000 ALTER TABLE `contact` ENABLE KEYS */;
UNLOCK TABLES;
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器