I use h2.1.3.154 embedded version. And my problem is that I can't get
h2 to enforce foreign key constraints when I try to insert a record to
a child table by leaving the foreign key column null.
Here are my tables:
CREATE TABLE person(
autoID INTEGER AUTO_INCREMENT,
personID VARCHAR(15) NOT NULL,
name VARCHAR(100) NOT NULL,
entryDate DATE,
lastUpdated TIMESTAMP,
CONSTRAINT pk_dataEntryPersonID PRIMARY KEY (personID));
CREATE TABLE grants (
grantsID VARCHAR(15) NOT NULL,
fundingStatus VARCHAR(255) NOT NULL,
title VARCHAR(500),
personID VARCHAR(15)
CONSTRAINT pk_grantID PRIMARY KEY (grantsID));
ALTER TABLE grants ADD CONSTRAINT
fk_personID FOREIGN KEY (personID)
REFERENCES person (personID)
ON UPDATE RESTRICT ON DELETE CASCADE;
Even though, the person table is completely blank, I can still make
entries in the grants table. I thought I should not be able to make
entries in the grants table because it has the "personID" column as a
foreign key referencing the person table's personID column. Is this
how it is supposed to work or is this bug or am I doing something
wrong?
Thank you for your help in advance.
Mak
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.