ORA-00904: "CUSTID": invalid identifier

200 Views Asked by At
create table Customer(
    Custid number (20) primary key,
    Custname char(20),
    phno number(10),
    pan varchar2(20),
    DOB date
    );

create table HomeLoan(
    HLoanid number (20) primary key,
    Amount number(10),
    foreign key(Custid) references Customer(Custid)
    );
    
create table VehicleLoan(
    VLoanid number (20) primary key,
    Amount number(10),
    foreign key(Custid) references Customer(Custid)
    );
    

When executing the above create table queries I received a error as

ORA-00904: “CUSTID”: invalid identifier

1

There are 1 best solutions below

0
Parker On

You forget to create column Custid in HomeLoan and VehicleLoan tables:

CREATE TABLE Customer (
    Custid number(20) PRIMARY KEY,
    Custname CHAR(20),
    phno number(10),
    pan varchar2(20),
    DOB DATE
    );

CREATE TABLE HomeLoan (
    HLoanid number(20) PRIMARY KEY,
    Amount number(10),
    Custid number(20),
    CONSTRAINT fk_customer FOREIGN KEY (Custid) REFERENCES Customer(Custid)
    );

CREATE TABLE VehicleLoan (
    VLoanid number(20) PRIMARY KEY,
    Amount number(10),
    Custid number(20),
    CONSTRAINT fk_customer FOREIGN KEY (Custid) REFERENCES Customer(Custid)
    );