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.为引用的表没有创建索引
上述报错是因为没有为引用的字段创建索引。
ERROR 1005 (HY000): Can't create table'matrix.system_log' (errno: 150)的更多相关文章
- 解决报错:ERROR 1005 (HY000): Can't create table 'market.orders' (errno: 150)
1.描述问题: 在这里我新建了两张表(customers_info和orders) 表一:customers_info CREATE TABLE customers_info ( c_num INT( ...
- Mysql错误问题:ERROR 1005 (HY000): Can't create table 'crm_1.tbl_client' (errno: 150)
MySQL外键创建条件: 1.两个表必须是InnoDB数据引擎2.外键表的外键字段必须是主键3.字段类型必须一致 创建表时创建外键: create table tbl_client(userName ...
- ERROR 1005 (HY000): Can't create table 'students.#sql-d9
今天在创建外键的时候出现以下错误 ERROR 1005 (HY000): Can't create table 'students.#sql-d99_3' (errno: 150) 格式 ...
- [MySQL]表创建外键失败:ERROR 1005 (HY000): Can't create table (errno: 150)
在数据库中建立一个新表(表引擎为InnoDB)时, 需要用到外键, 所以就在建表的时候加了一句foreign key (column) references table_name.但是执行时出现 ER ...
- mysql-error --(ERROR 1135 (HY000): Can't create a new thread (errno 11); if you are not out)
报错信息: ERROR 1135 (HY000): Can't create a new thread (errno 11); if you are not out 解决办法: # 查看限制情况 [r ...
- 错误代码: 1005 Can't create table 'hibernate.bill' (errno: 150)
主要问题以及解决办法是: 1,MySQL支持外键约束,并提供与其它DB相同的功能,但表(外键表和外键主表)类型必须为 InnoDB,外键表和外键主表的类型都要是innoDB 建表约束语句: user表 ...
- mysql为表添加外键完成性约束 报错Can't create table 'sfkbbs.#sql-513_25' (errno: 150)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtkAAAAyCAIAAAAGM1ChAAAAA3NCSVQICAjb4U/gAAAgAElEQVR4Xu
- ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI' (Errcode: 13)
mysql> desc tablename; ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI' (Errcode ...
- ERROR 1018 (HY000): Can't read dir of './test/' (errno: 13)
不能查看mysql中数据库的表. 一.查看 mysql> desc test; ERROR 1046 (3D000): No database selected mysql> use te ...
随机推荐
- c语言中赋值语句的结果
c语言中赋值语句的结果 最近在看<C语言接口与实现>,在第一章就发现一个以前很少用到的用法.在实现strcpy函数时,书中给出了两种实现. //version 1, 使用数组实现(新手惯用 ...
- Jquery 实现点击一个页面跳转后在另外一个页面显示指定位置
<script> $(function(){ var isTarget = '<?php echo $_GET['target']; ?>'; if (isTarget != ...
- 无线网络(WLAN)常见加密方式介绍
在使用无线路由器配置wifi安全设定的时候经常会遇到各种加密方式,即不懂意思也不知道如何选择.本文将对此做一个简单的介绍. 1.WEP 有线等效协议(Wired Equivalent Privacy, ...
- 转: adroid音视延迟 10ms的原因与解答
https://github.com/hehonghui/android-tech-frontier/blob/master/issue-9/Android%2010ms%E9%97%AE%E9%A2 ...
- 如何调试异步加载的js文件(浏览器调试动态加载js)
描述 1:jQuery->var obj= new $.js_Obj():等异步加载js文件,执行方法. obj.method(): 2:页面估计不变,通过声明不同的js文件,进行页面内容的转换 ...
- git学习之remote
修改远程仓库:$ git remote set-url --push [name] [newUrl] git pull 的时候报错 fatal: Authentication failed for ' ...
- java上传组件FileUpload
如果表单中有文件要上传,也就是有<input type="file" name="name"/> 就需要在form标签中添加enctype=&quo ...
- 转:C# 获取磁盘及CPU的序列号
原文地址:http://www.cnblogs.com/stray521/archive/2010/08/06/1793647.html //获取磁盘序列号 try { System.Manageme ...
- UEditor上传图片被压缩得模糊的解决方法
UEditor功能很强大,但是有个很不友好的功能:会在使用UEditor上传图片时,如果你的原始图片尺寸过大,就会先自动对图片大小进行压缩,然后将压缩的文件给servlet.也就是说,使用UEdito ...
- Javascript加载速度慢解决办法
通常我们的网站里面会加载一些js代码,统计啊,google广告啊,百度同盟啊,阿里妈妈广告代码啊,一堆,最后弄得页面加载速度很慢,很慢.解决办法:换一个js包含的方式,让javascript加载速度倍 ...