Skip to main content

SQL DDL und DML

DEMO

CREATE TABLE T (
    TID INTEGER PRIMARY KEY AUTOINCREMENT,
    W   INTEGER,TEXT,
    R   REAL,
    B   BLOB,
    UID INTEGER,
    D   INTEGER CHECK ( D >= 19000101),
    DIM INTEGER CHECK ( DIM >= 0),
    K   INTEGER CHECK ( K >= 0 AND K <= 100 ∗ DIM ),
    FOREIGN KEY ( W ) REFERENCES B ( BID ) ON DELETE CASCADE ,
    FOREIGN KEY ( UID ) REFERENCES U ( UID ) ON DELETE RESTRICT
);
ALTER TABLE T
    ADD TR INTEGER DEFAULT NULL REFERENCES B ( BID ) ON DELETE SET NULL;
INSERT INTO Training (Wer, UebungsID, Datum, VALUES
    ("3", "103" ,"20240326", "60", "100"),
    ("1", "102" ,"20240326", "60", "350");

ON DELETE

  • CASCADE
  • RESTRICT
  • ?????????