Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. -- The table referred:
  2. CREATE TABLE Categoria (
  3. Nome VARCHAR(50) NOT NULL,
  4. Immagine MEDIUMBLOB,
  5. PRIMARY KEY (Nome));
  6.  
  7. -- The table with FK:
  8. CREATE TABLE Sottocategoria_Di (
  9. Categoria1 VARCHAR(50) NOT NULL,
  10. Categoria2 VARCHAR(50) NOT NULL,
  11. PRIMARY KEY (Categoria1, Categoria2),
  12. FOREIGN KEY (Categoria1) REFERENCES Categoria(Nome) ON DELETE NO ACTION,
  13. FOREIGN KEY (Categoria2) REFERENCES Categoria(Nome) ON DELETE CASCADE);
  14.  
  15. INSERT INTO Categoria VALUES ('Chitarra', NULL);
  16. INSERT INTO Categoria VALUES ('Chitarra Acustica', NULL);
  17. INSERT INTO Categoria VALUES ('Chitarra Classica', NULL);
  18.  
  19. LOAD DATA INFILE "C:/ProgramData/MySQL/MySQL Server
  20. 8.0/Uploads/MusicShop/Sottocategoria.txt" INTO TABLE
  21. Music.Sottocategoria_Di
  22. CHARACTER SET latin1
  23. FIELDS TERMINATED BY '|'
  24. ENCLOSED BY ''
  25. LINES TERMINATED BY 'n'
  26. IGNORE 1 LINES
  27. (Categoria1,Categoria2);
  28.  
  29. -- Sottocategoria.txt
  30. Categoria1,Categoria2
  31. Chitarra Classica|Chitarra
  32. Chitarra Acustica|Chitarra`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement