Skip to main content

SQL DDL und DML

DEMO

CREATE TABLE T (
    TID INTEGER PRIMARY KEY AUTOINCREMENT,
    W   TEXT DEFAULT 'blabla',
    R   REAL,
    B   BLOB,
    UID INTEGER UNIQUE,
    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;
ALTER TABLE Tabelle
    DROP/ALTER COLUMN Spaltenname
INSERT INTO Training (Wer, UebungsID, Datum, VALUES
    ("3", "103" ,"20240326", "60", "100"),
    ("1", "102" ,"20240326", "60", "350");

ON DELETE

  • NO ACTION
  • SET DEFAULT
  • SET NULL
  • CASCADE
  • RESTRICT