SHARE
TWEET

SQLSQLSQLSQL

a guest Feb 14th, 2020 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.             CONSTRAIT employess
  3.             FOREIGN KEY (deptID)
  4.             REFERENCES Employee(id)
  5.             ON DELETE CASCADE
  6.             ON UPDATE CASCADE,
  7.            
  8.             CONSTRAIT pr_key
  9.             PRIMARY KEY (emplID,deptID) ON CONFLICT ROLLBACK
  10.             );
  11.  
  12. INSERT INTO Hired VALUES(101,1)
  13. INSERT INTO Hired VALUES(102,3,15000)
  14. INSERT INTO Hired VALUES(103,3,28000)
  15. INSERT INTO Hired VALUES(104,2,32000)
  16. INSERT INTO Hired VALUES(105,3,21000)
  17.  
  18. SELECT * FROM Department WHERE location LIKE 'Par%';
  19.  
  20. SELECT * FROM Employee WHERE id in
  21. (SELECT emplID FROM Hired WHERE deptID IS 3);
  22.  
  23. SELECT * FROM Employee WHERE id in
  24. (SELECT emplID FROM Hired WHERE deptID in
  25. (SELECT id FROM Department WHERE name LIKE 'Sal%'));
  26.  
  27. CREATE View TechEmpl(id,name,title) AS
  28. SELECT id,name,title FROM Employee WHERE id in
  29. (SELECT emplID FROM Hired WHERE deptID IS 3);
  30.  
  31. CREATE View Salary (salary,name,department) AS
  32. SELECT Hired.salary, Employee.name, Department.name
  33. FROM Employee, Hired,Department
  34. WHERE Employee.id = Hired.emplID AND Hired,deptID = Department.id
  35. ORDER BY Hired.salary;
  36.  
  37. SELECT * FROM TechEmpl ORDER BY name ASC;
  38.  
  39. SELECT * FROM Salary ORDER BY salary DESC;
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
Top