ON DELETE CASCADES and ON UPDATE CASCADES support in h2

4,851 views
Skip to first unread message

Alejandro Villamarin

unread,
Feb 13, 2014, 12:10:08 PM2/13/14
to h2-da...@googlegroups.com
Hi!

Does anybody knows if ON DELETE CASCADES and ON UPDATE CASCADES is supported in H2?

Suppose I have this:

DROP TABLE IF EXISTS SIBS;
CREATE TABLE SIBS (
    NAME VARCHAR(25) NOT NULL,
    SIB_ID VARCHAR(25) NOT NULL,
    CREATION_TIME VARCHAR(25),
    PRIMARY KEY(NAME, SIB_ID)
);

DROP TABLE IF EXISTS GATEWAYS;
CREATE TABLE GATEWAYS (
    ID SMALLINT AUTO_INCREMENT,
    NAME VARCHAR(25) NOT NULL,
    SIB_NAME VARCHAR(25) NOT NULL,
    SIB_ID VARCHAR(25) NOT NULL,
    GW_ID VARCHAR(25) NOT NULL,
    STATUS VARCHAR(20),
    TYPE VARCHAR(20),
    CREATION_TIME VARCHAR(25),
    PRIMARY KEY(ID),
        CONSTRAINT FK_SIB_GW FOREIGN KEY(SIB_NAME, SIB_ID) REFERENCES SIBS(NAME, SIB_ID) ON DELETE CASCADES
);

DROP TABLE IF EXISTS GWPROPERTIES;
CREATE TABLE GWPROPERTIES (
    ID SMALLINT AUTO_INCREMENT,
    NAME VARCHAR(25) NOT NULL,
    VALUE VARCHAR(100) NOT NULL,
    PRIMARY KEY(ID),
        CONSTRAINT FK_GW_PROP FOREIGN KEY(ID) REFERENCES GATEWAYS(ID) ON DELETE CASCADES
);

Obviously, if a SIB is deleted I want to delete all GATEWAYS associated, and the same goes for GWPROPERTIES if a GATEWAY is removed.

I can run some tests obviously, but before I'd like to ask here.

Thanks!
Alejandro

Rami Ojares

unread,
Feb 13, 2014, 5:48:27 PM2/13/14
to h2-da...@googlegroups.com

Alejandro Villamarin

unread,
Feb 13, 2014, 5:50:02 PM2/13/14
to h2-da...@googlegroups.com
Great, thank you!




--
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 h2-database+unsubscribe@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages