SHARE
TWEET

SQL TP2 1-4

a guest Mar 22nd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. CREATE TABLE OUVRAGE
  3. (
  4.   Numero INT NOT NULL,
  5.   Titre VARCHAR(20),
  6.   Auteur VARCHAR(30),
  7.   Editeur VARCHAR(10),
  8.   Prix INT,
  9.   Codetheme VARCHAR(2),
  10.   Constraint ouvrage_id PRIMARY KEY(Numero),
  11.   Constraint codetheme_id FOREIGN KEY(Codetheme) REFERENCES THEME
  12. );
  13.  
  14.  
  15. CREATE TABLE THEME
  16. (
  17.   Code VARCHAR(2),
  18.   Libelle VARCHAR(20),
  19.   Constraint code_id PRIMARY KEY(Code)
  20. );
  21.  
  22.  
  23. ALTER TABLE OUVRAGE
  24. MODIFY Editeur VARCHAR(20);
  25.  
  26. ALTER TABLE OUVRAGE
  27. ADD Date_achat DATE;
  28.  
  29. ALTER TABLE OUVRAGE
  30. DROP CONSTRAINT codetheme_id;
  31.  
  32. ALTER TABLE OUVRAGE
  33. ADD CONSTRAINT codetheme_id FOREIGN KEY (Codetheme) REFERENCES THEME ON DELETE CASCADE;
  34.  
  35. INSERT INTO THEME
  36. VALUES ('BD','Base de donnees');
  37.  
  38. INSERT INTO THEME
  39. VALUES ('LE','Litterature');
  40.  
  41. INSERT INTO THEME
  42. VALUES ('ME','Metho');
  43.  
  44. INSERT INTO OUVRAGE --(Numero, Titre, Auteur, Editeur, Prix, Codetheme, Date_achat)
  45. VALUES(1, 'SQL', 'Date', 'InterEditions', 29.90, 'BD', DATE'2008-09-09');
  46. INSERT INTO OUVRAGE
  47. VALUES(10, 'Merise', 'Laroche', 'Dunod', 35.50, 'LE', DATE'2009-08-25');
  48. INSERT INTO OUVRAGE
  49. VALUES(15, 'Le rouge et le noir', 'Stendhal', 'Folio', 5.50, 'ME', DATE'2010-03-31');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top