SQL Error: Ora-02291: Integrity Constraint

SQL Error: ORA-02291: integrity constraint

Try inserting in your TypeComponent table first, then insert into your Component table.

According to the error:

ORA-02291:    integrity constraint (string.string) violated - parent key not found

Cause:            A foreign key value has no matching primary key value.

Action:            Delete the foreign key or add a matching primary key.

This means that there is no matching key in your referenced table.


For your kind information, here is a site where you can get help with all of the Oracle error codes.


Here's the homepage for this site: http://www.ora-code.com/

Where you may replace the error code in the URL to suit the error code you're getting, and you'll access to the page for this error.

Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02291: integrity constraint violated - parent key not found

The value inserted into the book_id column of the Review table should be in the Book Table.If not, it throws an error like this.

Why am I violating an integrity constraint? (ORA-02291)

You need the "Marvel: Iron Man" franchise to exist before you insert "Iron Man" into Movie.

Also, you should always use explicit column names in INSERT statements.

INSERT INTO Franchise ( Fran_Name )
VALUES ( 'Marvel: Iron Man' )

INSERT INTO Movie ( Movie_Title, Screen_Time, M_Reviews, Fran_name )
VALUES( 'Iron Man 2', 124, 7.0, 'Marvel: Iron Man' );

...and more controversially, I feel database tables should have plural names if the table represents an unbounded collection. (I look forward to the dozen or so comment replies from people who disagree ;) )

Related Topics

Leave a reply