We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

oracle primary key and foreign key within same table

How can I insert two row to supplier table?

CREATE TABLE supplier (
    supplier_nr NUMBER(10),

    supplier_id VARCHAR2(20) NOT NULL,

    price   NUMBER(10) NOT NULL,

    CONSTRAINT supplier_supplier_nr_pk PRIMARY KEY(supplier_nr),
    CONSTRAINT supplier_supplier_id_fk FOREIGEN KEY(supplier_id)
        REFERENCES varugrupp(supplier_id)
);
2
Contributors
4
Replies
7 Hours
Discussion Span
3 Months Ago
Last Updated
19
Views
Question
Answered
tony75
Junior Poster
164 posts since Mar 2011
Reputation Points: 20
Solved Threads: 4
Skill Endorsements: 0

Insert the rows with a unique supplier_nr for each row and an existing supplier_id.

pritaeas
Posting Prodigy
Moderator
9,534 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98

Can you give me one example please!

tony75
Junior Poster
164 posts since Mar 2011
Reputation Points: 20
Solved Threads: 4
Skill Endorsements: 0
INSERT INTO supplier VALUES (1, 'ID', 10)

The values shown above depend on what is already in your tables, so you may need to change those. For example 'ID' needs to be in the varugrupp table.

pritaeas
Posting Prodigy
Moderator
9,534 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,494
Skill Endorsements: 98

THANKS SIR

tony75
Junior Poster
164 posts since Mar 2011
Reputation Points: 20
Solved Threads: 4
Skill Endorsements: 0
Question Answered as of 3 Months Ago by pritaeas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.6046 seconds using 2.67MB