我有一个数据库表,其主键是自动递增的值
如何在不插入此值的情况下将数据插入此表中,该值应该自行更新
这是我的桌子:
CREATE TABLE IF NOT EXISTS
Users(lastName CHAR(50) NOT NULL,
userID MEDIUMINT NOT NULL AUTO_INCREMENT,
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 UNIQUE,
firstName CHAR(50) NOT NULL,
PRIMARY KEY (userID),password CHAR(30) NOT NULL);
这是我的插入语句:
(firstName,lastName,login,password,address,email) VALUES(?,?,?,?,?,?)
这是我得到的例外:
java.sql.SQLException: Field 'userID' doesn't have a default value
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:2815)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at com.database.Main.main(Main.java:15)