Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 3.13 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. distinct spz
  2.  
  3. set typ = 'O'
  4.  
  5. set nazov_sluzby='svetielka'
  6.  
  7. select first_name,last_name,job_title,department_name from employees join jobs using(job_id) join departments using(department_id) where job_title like '%Manager%';
  8.  
  9. select first_name, last_name, department_name, city from hr.employees e join hr.departments d on d.manager_id = e.employee_id join hr.locations using(location_id) where city like'%Seattle%' ;
  10.  
  11. select department_name, count(*) from hr.employees join hr.departments using(department_id) group by department_name having count(*) between 5 and 10;
  12.  
  13. select department_id, job_id, count(*) from employees where department_id in(50, 80) group by job_id, department_id having count(*) >= 20;
  14.  
  15. select department_name, city, country_name from departments join locations using(location_id) join countries using(county_id) order by 3, 2, 1;
  16.  
  17. select department_name, max(salary) from hr.employees join hr.departments using(department_id) where department_name like 'Finance' group by department_name;
  18.  
  19. select department_name, avg(salary) from hr.employees join hr.departments using(department_id) where department_name = 'Sales' group by department_name;
  20.  
  21. select avg(salary), count(employee_id) from hr.employees where job_id in ('SA_REP');
  22.  
  23. select count(*) from hr.employees where department_id = 50;
  24.  
  25. select min(last_name) from employees;
  26.  
  27. delete from auto where spz like 'KE%';
  28.  
  29. delete auto where typ in('o','O');
  30.  
  31. delete from sluzba where cena_sluzby > 15;
  32.  
  33. select min(cena_sluzby), max(cena_sluzby), avg(cena_sluzby) from sluzba;
  34.  
  35. select spz, count(*) from asz having count(*)>2 group by spz;
  36.  
  37. TEORETICKE:
  38.  
  39. REL.operacia join: kombinovanie suvisiacich zaznamov z dvoch relacii do jednoduchych zaznamov
  40.  
  41. Operacia relacnej algebry projekcia:
  42.         -vekrikalny vyber
  43.         -vyber urcitych atributov z relacie
  44.  
  45. Podmienka s rel. operatormi(<,>,=.....): -theta join
  46.  
  47. Medzi mnozinove operacie rel. algebry patria:
  48.         -rozdiel
  49.         -karteziansky sucin
  50.         -zjednotenie
  51.         -prienik
  52.  
  53. Relacia nad ktorymi sa aplikuje KARTEZIANSKY sucin: nemusia byt kompatibilne vzhladom k zjednoteniu
  54.  
  55. Sucastne tvrdenie pre operacie: zjednotenie, prienik, rozdiel:
  56.         -operacie su kompatibilne vzhladom k zjednoteniu
  57.  
  58. Vysledok operacie zjednotenie (union) R u S je relacia, ktora obsahuje vsetky zaznamy ktore:
  59.         -patria bud do R alebo do S alebo do R aj S. Duplicitne zaznamy su eliminovane
  60.  
  61. Pocet zaznamov vo vysledku projekcie ak zoznam atributov obsahuje kluc relacie:
  62.         -je mensi alebo rovny poctu zaznamov v povodnej relacii. Duplicitne zaznamy su implicitne eliminovane
  63.  
  64. Podmienka spojenia v operacii spojenie je specifikovana:
  65.         -nad atributmi z dvoch relacii R a S, ktore maju rovnaku domenu a maju rovnaky semanticky vyznam
  66.  
  67. Operacia R right outer join S zachovava:
  68.         -kazdy zaznam v druhej relacii S vo vysledku R right outer join S. Ak ziadny zodpovedajuci zaznam       nie je najdeny v relacii R, potom atributy R vo vysledku su vyplnene hodnotami NULL
  69.  
  70. alter table uloha add check(end_date > start_date);
  71. alter table uloha modify end_date date check (end_date > start_date);
  72.  
  73. KONSTRUKCIA databazy je: proces ukladania dat na nejake pamatove medium riadeny SRBD