Facebook
From SDF, 5 Days ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 29
  1. --CREATE TABLE ZESP1 (NR_ZESP SMALLINT(6) PRIMARY KEY, NAZWA_ZESP CHAR(30),
  2. --NR_PRAC_KZ INT(11), NR_INST SMALLINT(6)) ENGINE = InnoDB;
  3. --CREATE TABLE PRAC1 (NR_PRAC INT(11) PRIMARY KEY, PLEC CHAR(1) NOT NULL,
  4. --DATA_UR DATETIME, NAZWISKO CHAR(15), NR_ZESP SMALLINT(6)) ENGINE = InnoDB;
  5. --CREATE INDEX I_NR_ZESP ON PRAC1(NR_ZESP);
  6. --INSERT INTO ZESP1 SELECT * FROM ZESPOLY;
  7. --INSERT INTO PRAC1 SELECT * FROM PRACOWNICY;
  8. --ALTER TABLE ZESP1 ADD FOREIGN KEY (NR_PRAC_KZ) REFERENCES PRAC1(NR_PRAC) ON DELETE RESTRICT;
  9. --ALTER TABLE PRAC1 ADD FOREIGN KEY (NR_ZESP) REFERENCES ZESP1(NR_ZESP) ON DELETE SET NULL;
  10. --INSERT INTO PRAC1 (NR_PRAC, PLEC, DATA_UR, NAZWISKO, NR_ZESP) VALUES (1, 'M', '1992-10-31 00:00:00', 'PRZYBYLIK', 1) --DUPLICATE ENTRY ON KEY PRIMARY
  11. --INSERT INTO PRAC1 (NR_PRAC, PLEC, DATA_UR, NAZWISKO, NR_ZESP) VALUES (42, 'M', '1992-10-31 00:00:00', 'PRZYBYLIK', 60) --FOREIGN KEY
  12. --DELETE FROM `zesp1` WHERE (`NR_ZESP`=1); OK POLA PRACOWNIKOW ZESPOL = NULL
  13. --DELETE FROM `prac1` WHERE (`NR_PRAC`=2); /* SQL Error (1451): Cannot delete or update a parent row: a foreign key constraint fails ("uczelnia"."zesp1", CONSTRAINT "zesp1_ibfk_1" FOREIGN KEY ("NR_PRAC_KZ") REFERENCES "prac1" ("NR_PRAC")) */