错误代码: 1005 Can't create table 'hibernate.bill' (errno: 150)
Posted Fight With Me!!!
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了错误代码: 1005 Can't create table 'hibernate.bill' (errno: 150)相关的知识,希望对你有一定的参考价值。
主要问题以及解决办法是:
1,mysql支持外键约束,并提供与其它DB相同的功能,但表(外键表和外键主表)类型必须为 InnoDB,外键表和外键主表的类型都要是innoDB
建表约束语句:
user表:
1
2
3
4
5
6
|
CREATE TABLE `usert` ( `id` int (11) NOT NULL AUTO_INCREMENT, ` password ` varchar (255) COLLATE utf8_unicode_ci DEFAULT NULL , `userName` varchar (255) COLLATE utf8_unicode_ci DEFAULT NULL , PRIMARY KEY (`id`) ) ENGINE=InnoDB |
bill新表中有一个外键约束 tb_bill_fk指向 user表中的id :
1
2
3
4
5
|
CREATE TABLE bill ( id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, user_id INT , CONSTRAINT FOREIGN KEY tb_bill_fk (user_id) REFERENCES usert(id) ) ENGINE=INNODB |
以上是关于错误代码: 1005 Can't create table 'hibernate.bill' (errno: 150)的主要内容,如果未能解决你的问题,请参考以下文章
ERROR 1005 (HY000): Can't create table'matrix.system_log' (errno: 150)
错误代码 1007 Can't create database 'test' database exists
(转)ERROR 2002 (HY000): Can't connect to local MySQL server through socket '***' (示例代码(代码
2019-08-18 Pycharm的运行错误can't find '__main__' module
python3 UnicodeEncodeError错误,cx_oracle模块执行sql报错:UnicodeEncodeError: 'ascii' codec can't
Python读取中文txt文件错误:UnicodeEncodeError: 'gbk' codec can't encode character