Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:28:19+00:00 2026-06-12T06:28:19+00:00

I have created some SQL code to create 7 tables based off an ERD.

  • 0

I have created some SQL code to create 7 tables based off an ERD.

It seems to be extremely close to working, except that it says that

column “inv_no” referenced in foreign key constraint does not exist

However, the table invoice which inv_no is in is created, and has the column inv_no so I am very confused how it does not exist to create the other table invoiceLine which requires inv_no as a foreign key.

Here is my code:

CREATE TABLE invoice(

        inv_no          INTEGER         NOT NULL,
        cust_id         INTEGER         NOT NULL,
        inv_date        DATE            NOT NULL,
CONSTRAINT PK_invoice_inv_no PRIMARY KEY(inv_no),
CONSTRAINT FK_customer_cust_id FOREIGN KEY(cust_id) REFERENCES customer(cust_id)
);

CREATE TABLE invoiceLine(

        inv_line_no     INTEGER         NOT NULL,
        inv_line_qty    INTEGER         NOT NULL,
CONSTRAINT PK_invoiceLine_inv_line_no PRIMARY KEY(inv_line_no),
CONSTRAINT FK_invoice_inv_no FOREIGN KEY(inv_no) REFERENCES invoice(inv_no)
);

Again, the table in question is invoiceLine which seems to be dependent on inv_no in the invoice table.

If anyone can spot my error that would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:28:20+00:00Added an answer on June 12, 2026 at 6:28 am

    The error message is correct there is no column inv_no in invoiceline. You need to declare that column as well:

    CREATE TABLE invoiceLine(
           inv_no          INTEGER         NOT NULL,
           inv_line_no     INTEGER         NOT NULL,
           inv_line_qty    INTEGER         NOT NULL,
    CONSTRAINT PK_invoiceLine_inv_line_no PRIMARY KEY(inv_line_no),
    CONSTRAINT FK_invoice_inv_no FOREIGN KEY(inv_no) REFERENCES invoice(inv_no)
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written some SQL code to create five tables with several relations(foreign keys).
I need to execute some large file-based .sql scripts (to create/drop databases and tables
I have created some Procedures in SQL Developer, and they are working fine. However
I created and launch the SQLJ Java procedure (using SQL Developer). I have some
I have defined a table type PL/SQL variable and added some data there. create
I have created some python code which creates an object in a loop, and
I have created some tests in my WPF application. Right now I am working
Hello StackOverflow :) I have created some code inside my onStart(); method to ensure
I am trying to create a rich text editor. I have created some buttons
I have created some JQuery that will expand a div 'popup' on hover and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.