ERROR 1005 (HY000): Can't create table'matrix.system_log' (errno: 150)
CREATE TABLE `user` (
`id` bigint(32) NOT NULL AUTO_INCREMENT ,
`name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`erp` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' ,
`email` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`department` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`position` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`role` int(1) NOT NULL ,
`lastProductID` bigint(32) NULL DEFAULT NULL ,
`userIP` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`debugRunStatus` int(1) NULL DEFAULT NULL ,
`createTime` datetime NULL DEFAULT NULL ,
`remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho1Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho2Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho3Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho4Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho5Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`modifyTime` datetime NULL DEFAULT NULL ,
`defaultType` int(11) NULL DEFAULT NULL ,
PRIMARY KEY (`id`, `erp`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=486
;
CREATE TABLE `system_log` (
`id` bigint(32) NOT NULL AUTO_INCREMENT ,
`erp` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`operType` int(11) NOT NULL DEFAULT 0 COMMENT '1 ---登入' ,
`operTime` datetime NOT NULL ,
`remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`browerIP` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`modifyTime` datetime NOT NULL ,
PRIMARY KEY (`id`),
FOREIGN KEY (`erp`) REFERENCES `user` (`erp`) ON DELETE CASCADE ON UPDATE RESTRICT
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=2247
;
報錯資訊如下:
ERROR 1005 (HY000): Can't create table 'matrix.system_log' (errno: 150)
mysql> show engine innodb status\G
140303 13:58:42 Error in foreign key constraint of table matrix/system_log:
FOREIGN KEY (`erp`) REFERENCES `user` (`erp`) ON DELETE CASCADE ON UPDATE RESTRICT
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=2247:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
報錯原因有如下幾種原因:
1.欄位型別不一致
2.引用的欄位和被引用的欄位“NULL”屬性不一致
3.為引用的表沒有建立索引
上述報錯是因為沒有為引用的欄位建立索引。
`id` bigint(32) NOT NULL AUTO_INCREMENT ,
`name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`erp` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' ,
`email` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`department` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`position` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`role` int(1) NOT NULL ,
`lastProductID` bigint(32) NULL DEFAULT NULL ,
`userIP` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`debugRunStatus` int(1) NULL DEFAULT NULL ,
`createTime` datetime NULL DEFAULT NULL ,
`remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho1Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho2Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho3Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho4Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`ho5Name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`modifyTime` datetime NULL DEFAULT NULL ,
`defaultType` int(11) NULL DEFAULT NULL ,
PRIMARY KEY (`id`, `erp`)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=486
;
CREATE TABLE `system_log` (
`id` bigint(32) NOT NULL AUTO_INCREMENT ,
`erp` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
`operType` int(11) NOT NULL DEFAULT 0 COMMENT '1 ---登入' ,
`operTime` datetime NOT NULL ,
`remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`browerIP` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ,
`modifyTime` datetime NOT NULL ,
PRIMARY KEY (`id`),
FOREIGN KEY (`erp`) REFERENCES `user` (`erp`) ON DELETE CASCADE ON UPDATE RESTRICT
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=2247
;
報錯資訊如下:
ERROR 1005 (HY000): Can't create table 'matrix.system_log' (errno: 150)
mysql> show engine innodb status\G
140303 13:58:42 Error in foreign key constraint of table matrix/system_log:
FOREIGN KEY (`erp`) REFERENCES `user` (`erp`) ON DELETE CASCADE ON UPDATE RESTRICT
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci
AUTO_INCREMENT=2247:
Cannot find an index in the referenced table where the
referenced columns appear as the first columns, or column types
in the table and the referenced table do not match for constraint.
Note that the internal storage type of ENUM and SET changed in
tables created with >= InnoDB-4.1.12, and such columns in old tables
cannot be referenced by such columns in new tables.
See http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html
for correct foreign key definition.
報錯原因有如下幾種原因:
1.欄位型別不一致
2.引用的欄位和被引用的欄位“NULL”屬性不一致
3.為引用的表沒有建立索引
上述報錯是因為沒有為引用的欄位建立索引。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-1098671/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【MySQL】ERROR 1005 (HY000): Can't create table' (errno: 150)MySqlError
- ERROR 1005 (HY000): Can't create table 'starive.SC' (errno: 150)"Error
- ERROR 1135 (HY000): Can't create a new thread (errno 11)Errorthread
- ERROR 1135 (HY000): Can't create a new threadErrorthread
- MySQL案例-不同尋常的[ERROR]Can't create a new thread (errno 11)MySqlErrorthread
- [ERROR] Can't open the mysql.plugin tableErrorMySqlPlugin
- mysql [ERROR] Can't create IP socket: Permission deniedMySqlError
- ERROR 1786 (HY000): Statement violates GTID consistency: CREATE TABLE ... SELECTError
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- ERROR 2002 (HY000): Can't connect server socket /tmp/mysql.sockErrorServerMySql
- MYSQL ERROR 2003 (HY000) CanMySqlError
- 解決Error (1133): Can’t find any matching row in the user tableError
- Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist解決辦法ErrorMySql
- MySQL 5.7向表匯入資料包錯"ERROR 13 (HY000): Can't get stat of"MySqlError
- MySQL報錯'ERROR 2002 (HY000): Can't connect to local MySQL server through'MySqlErrorServer
- ERROR 2003 (HY000)Can't connect to MySQL server on '192.168.8.247' (113)ErrorMySqlServer
- ERROR 2002(HY000):Can't connect to local MySQL socket '/tmp/mysql.sock'ErrorMySql
- ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)ErrorMySqlServerlocalhost
- MySQL "ERROR 1010(HY000):Error dropping database(canMySqlErrorDatabase
- ERROR 2002 (HY000): Can't connect server socket /var/run/mysqld/mysqld.sockErrorServerMySql
- ERROR 1114 (HY000) The table '' is fullError
- can't create PID file問題處理
- [ERROR] mysqld: Can‘t open shared library ‘/usr/local/mysql/lib/plugin/validate_password.so‘ (errno:ErrorMySqlPlugin
- T-SQL的CREATE TABLE語法(下)SQL
- T-SQL的CREATE TABLE語法(上)SQL
- ERROR in Entry module not found Error Can't resolve 'babel' in ' UseErrorBabel
- You can‘t specify target table ‘Person‘ for update in FROM clause
- mysql中You can’t specify target table for update in FROM clMySql
- [筆記].痛哉!!!Error: Can't access JTAG chain, Error: Operation failed筆記ErrorAI
- ERROR 1168 (HY000): Unable to open underlying table which isError
- Mysql報錯Fatal error:Can't open and lock privilege tablesMySqlError
- mysql can't connect error about privilege----not root userMySqlError
- MySQL ERROR 1031 (HY000) at line 33: Table storage engine forMySqlError
- ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default valueError
- ?Error: Can't locate /etc/centreon/conf.pm in @INC (@INError
- MySQL 建立外來鍵報錯Can't write; duplicate key in tableMySql
- ERROR 1206 (HY000): The total number of locks exceeds the lock table sizeError
- Error:Can't connect to SOCKS proxy:Connection refused (Connection refused)Error