如何编写 sql 查询以使用 jdbc 在 2 列上创建具有唯一约束的表:我尝试此代码并给我“SQLException:无效的创建语句!”:
Connection conn = ConnectDB.getConnection();
Statement stmt = null;
try {
String sql = "CREATE TABLE TBL_fonts" +
+ "(char_id int not NULL, "
+ "FW VARCHAR(255), "
+ "code VARCHAR(255), "
+ "character VARCHAR(255), "
+ "CONSTRAINT fontConst UNIQUE(FW,code), "
+ "PRIMARY KEY (char_id))";
stmt = conn.createStatement();
stmt.executeUpdate(sql);
conn.commit();
} catch (SQLException ex) {
ex.printStackTrace();
}