daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --1)
  2. CREATE TABLE TOUR AS SELECT * FROM DOCENCIA.TOUR2017;
  3. --SELECT * FROM TOUR;
  4.  
  5. --2)
  6. CREATE TABLE INFO_PERSONAL AS SELECT ID,NAME,NATIONALITY FROM TOUR;
  7. ALTER TABLE INFO_PERSONAL ADD PRIMARY KEY (ID);
  8.  
  9. CREATE TABLE INFO_PROFESIONAL AS SELECT ID,TEAM,COUNTRY,CATEGORY FROM TOUR;
  10. ALTER TABLE INFO_PROFESIONAL ADD PRIMARY KEY (ID);
  11.  
  12. --3)
  13. CREATE VIEW TOUR_VIEW AS SELECT * FROM TOUR;
  14. --SELECT * FROM TOUR_VIEW;
  15.  
  16. --4)
  17.  
  18. CREATE OR REPLACE TRIGGER tr_inserta_ciclista
  19. INSTEAD OF INSERT ON TOUR_VIEW
  20. FOR EACH ROW
  21. BEGIN
  22.     INSERT INTO INFO_PERSONAL(ID,NAME,NATIONALITY)
  23.     SELECT ID,NAME,NATIONALITY
  24.     FROM TOUR_VIEW;
  25.  
  26.     INSERT INTO INFO_PROFESIONAL(ID,TEAM,COUNTRY,CATEGORY)
  27.     SELECT ID,TEAM,COUNTRY,CATEGORY
  28.     FROM TOUR_VIEW;
  29. END tr_inserta_ciclista;
  30.  
  31. --INSERT INTO TOUR_VIEW(ID,TEAM,COUNTRY,NAME,NATIONALITY,CATEGORY)
  32. --    VALUES(220,'TEAM DANIAT', 'Spain', 'DANIEL CASTLE', 'ESP', 'WorldTour');
  33.  
  34. --5)
  35. CREATE TABLE LOG_INSERCION (
  36.     USUARIO VARCHAR2(20),
  37.     FECHA DATE
  38. );
  39.  
  40. CREATE OR REPLACE TRIGGER tr_inserta_old
  41. AFTER INSERT ON TOUR
  42. FOR EACH ROW
  43. BEGIN
  44.     INSERT INTO LOG_INSERCION(USUARIO,FECHA)
  45.     VALUES(USER,SYSDATE);
  46. END tr_inserta_old;
RAW Paste Data
Top