簡體   English   中英

無法在mysql中創建表錯誤(150)

[英]Cannot create a table in mysql error(150)

我想創建3個表,分別稱為curenttasks,originaltasks和previoustasks。 我制作一張桌子,然后復制到另外兩張桌子。 但是一個表不能創建,而其他兩個表則可以成功創建。

這三個表是:

DROP TABLE IF EXISTS `CurrentTasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `CurrentTasks` (
  `taskID` mediumint(9) NOT NULL AUTO_INCREMENT,
  `taskName` varchar(255) NOT NULL,
  `isActive` boolean DEFAULT TRUE,   
  `startDate` datetime NOT NULL,
  `endDate` datetime NOT NULL,
  `completeDate` datetime DEFAULT NULL,
  `complexityID` smallint(6) NOT NULL,
  `managerID` mediumint(9) NOT NULL,
  `projectID` mediumint(9) NOT NULL,
  `requirementName` varchar(255) NOT NULL,
  `xPos` smallint(6) DEFAULT NULL,
  `yPos` smallint(6) DEFAULT NULL,
  `description` text NOT NULL,
  `stageName` enum('Definition','Design','Development','Testing','Evaluation') NOT NULL DEFAULT 'Definition',
  PRIMARY KEY (`taskID`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `CurrentTasks`
--

LOCK TABLES `PreviousTasks` WRITE;
/*!40000 ALTER TABLE `PreviousTasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `PreviousTasks` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `PreviousTasks`
--

DROP TABLE IF EXISTS `PreviousTasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `PreviousTasks` (
  `taskID` mediumint(9) NOT NULL AUTO_INCREMENT,
  `taskName` varchar(255) NOT NULL,
  `isActive` boolean DEFAULT TRUE,   
  `startDate` datetime NOT NULL,
  `endDate` datetime NOT NULL,
  `completeDate` datetime DEFAULT NULL,
  `complexityID` smallint(6) NOT NULL,
  `managerID` mediumint(9) NOT NULL,
  `projectID` mediumint(9) NOT NULL,
  `requirementName` varchar(255) NOT NULL,
  `xPos` smallint(6) DEFAULT NULL,
  `yPos` smallint(6) DEFAULT NULL,
  `description` text NOT NULL,
  `stageName` enum('Definition','Design','Development','Testing','Evaluation') NOT NULL DEFAULT 'Definition',
  PRIMARY KEY (`taskID`),
  UNIQUE KEY `uniquePreviousTasks` (`requirementName`,`projectID`,`taskName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `PreviousTasks`
--

LOCK TABLES `PreviousTasks` WRITE;
/*!40000 ALTER TABLE `PreviousTasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `PreviousTasks` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `OriginalTasks`
--

DROP TABLE IF EXISTS `OriginalTasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `OriginalTasks` (
  `taskID` mediumint(9) NOT NULL AUTO_INCREMENT,
  `taskName` varchar(255) NOT NULL,
  `isActive` boolean DEFAULT TRUE,
  `startDate` datetime NOT NULL,
  `endDate` datetime NOT NULL,
  `completeDate` datetime DEFAULT NULL,
  `complexityID` smallint(6) NOT NULL,
  `managerID` mediumint(9) NOT NULL,
  `projectID` mediumint(9) NOT NULL,
  `requirementName` varchar(255) NOT NULL,
  `xPos` smallint(6) DEFAULT NULL,
  `yPos` smallint(6) DEFAULT NULL,
  `description` text NOT NULL,
  `stageName` enum('Definition','Design','Development','Testing','Evaluation') NOT NULL DEFAULT 'Definition',
  PRIMARY KEY (`taskID`),
  UNIQUE KEY `uniqueOriginalTasks` (`requirementName`,`projectID`,`taskName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `OriginalTasks`
--

LOCK TABLES `OriginalTasks` WRITE;
/*!40000 ALTER TABLE `OriginalTasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `OriginalTasks` ENABLE KEYS */;
UNLOCK TABLES;

當前任務無法執行,錯誤是:

錯誤1005(HY000):無法創建表'rem.currenttasks'(errno:150)

我只是很困惑,因為我刪除了currenttasks並將其復制到以前的任務,用當前替換所有先前的任務,但是它仍然無法工作。

您忘記刪除28-31之間的行。 PreviousTasks表尚未創建,但是這些行嘗試更改表。 第64-67行也存在同樣的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM