Hello.

Indexes may be shared between constraints.

In the SQL Standard referential constraints may reference only columns with 
already existing unique constraint. It isn't ensured by released versions 
of H2, they allow referential constraints without unique constraints and 
reuse their indexes.

Current H2 doesn't require it too, but creates a unique constraint 
automatically if it doesn't exists. Attempt to drop the unique constraint 
is disallowed by default and allowed with CASCADE clause and with such 
clause the referential constraint is also dropped.
CREATE TABLE T1(ID INT, CONSTRAINT PK1 PRIMARY KEY(ID));
> ok
CREATE TABLE T2(ID INT, F INT,
    CONSTRAINT PK2 PRIMARY KEY(ID),
    CONSTRAINT FK2 FOREIGN KEY(F) REFERENCES T1);
> ok
ALTER TABLE T2 DROP CONSTRAINT PK1;
> Constraint "PUBLIC.PK1" is used by constraint "PUBLIC.FK2"
ALTER TABLE T2 DROP CONSTRAINT PK1 CASCADE;
> ok

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/2eefcf94-d1ec-47cb-9bd4-17edc35decb7%40googlegroups.com.

Reply via email to