But what about my example that I recently posted on the list
"Joyful surprise: H2 supports db constraints!"

Doesn't it demonstrate that you can refer to the table in a constraint that is just being created?

CREATE TABLE A (ID INT PRIMARY KEY);
CREATE TABLE B (AID INT REFERENCES A);
CREATE TABLE C (
    AID INT REFERENCES A,
    CONSTRAINT DB_CONSTRAINT CHECK(
        EXISTS(
            SELECT *
            FROM A
            JOIN B
            ON C.AID = A.ID AND A.ID = B.AID
        )
    )
);

INSERT INTO A VALUES(1);
INSERT INTO C VALUES(1);
INSERT INTO B VALUES(1);
INSERT INTO C VALUES(1);

--
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.

Reply via email to