“在创建表时缺少关系中的列]

问题描述 投票:2回答:1

我已经尝试创建三个表(CUSTOMERS,VEHICLES和RENTALS),第三个表(RENTALS)具有引用前两个表的两个主键(CUSTOMERS和RENTALS)的外键。创建第三个表时,出现错误关系中缺少列(Rel = CUSTOMERS [[]]-> RENTALS [[]])] >>

这是我的代码

     private void createTables() throws SQLException {
        Statement statement = conn.createStatement();
        statement.executeUpdate("CREATE TABLE CUSTOMERS(custNumber AUTOINCREMENT PRIMARY KEY, " +
            "firstName VARCHAR(155) NOT NULL, surname VARCHAR(155) NOT NULL, idNum INTEGER NOT NULL, phoneNum INTEGER NOT NULL, canRent BIT NOT NULL)");
        statement.executeUpdate("CREATE TABLE VEHICLES(vehNumber AUTOINCREMENT PRIMARY KEY, make VARCHAR(155) NOT NULL, " +
            "category VARCHAR(155) NOT NULL, rentalPrice FLOAT NOT NULL, availableForRent BIT NOT NULL)");
        statement.executeUpdate("CREATE TABLE RENTALS(rentalNumber AUTOINCREMENT PRIMARY KEY, dateRental VARCHAR(155) NOT NULL, dateReturned VARCHAR(155) NOT NULL, " +
            "pricePerDay FLOAT NOT NULL, totalRental FLOAT NOT NULL, custNumber INTEGER FOREIGN KEY REFERENCES CUSTOMERS(custNumber), " +
            "vehNumber INTEGER FOREIGN KEY REFERENCES VEHICLES(vehNumber))");

        System.out.println("Database populated");
     }

这是错误enter image description here

非常感谢您的帮助,我环顾四周,但没有发现任何帮助。

我已经尝试创建三个表(CUSTOMERS,VEHICLES和RENTALS),第三个表(RENTALS)具有引用前两个表的两个主键(CUSTOMERS和RENTALS)的外键。当...

java sql ms-access jdbc ucanaccess
1个回答
3
投票
© www.soinside.com 2019 - 2024. All rights reserved.