我正在尝试通过代码在 mysql 数据库中创建两个表
这是我的创作脚本
CREATE DATABASE if not exists feedback;
CREATE TABLE IF NOT EXISTS Authorizations(
authDesc CHAR(50),
id MEDIUMINT NOT NULL AUTO_INCREMENT,
authLevel INT NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS Users(
lastName CHAR(50) NOT NULL,
userID MEDIUMINT NOT NULL,
phone CHAR(15),
email CHAR(50),
address CHAR(100),
authLevel INT NOT NULL DEFAULT 0,
FOREIGN KEY(authLevel) REFERENCES Authorizations (authLevel),
login CHAR(30) NOT NULL,
firstName CHAR(50) NOT NULL,
PRIMARY KEY (login),password CHAR(30) NOT NULL
);
尝试执行该错误时出现此错误
java.sql.SQLException: Can't create table 'feedback.users' (errno: 150)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2809)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725)
at com.database.Database.createDatabase(Database.java:45)
at com.database.Main.main(Main.java:6)
第 45 行在我的代码中有 create table users 行
我的数据库引擎是 InnoDB,通过 mysql
我究竟做错了什么 ?