Functie de inserare rand (instanta) intr-un tabel
(Sectiunea 12, Lectia 1, Slide 7)
insert into <table name> values (value1, value2, ...)
Value reprezinta atributele din coloanele existente (poate fi si null)
Adaugarea unei coloane noi la un tabel
S 12, L 2
alter table <table name> add (<column_name> <data type>)
Column name fara ' '
Stergerea unei coloane
alter table <table name> drop column <column name>
Stergerea unui rand
Delete from <table name> where <column name> = ' some value '
Proiectie - alegerea a uneia sau mai multor coloane
Selectie - alegerea a unuia sau mai multor randuri
select distinct department_id from employees - afiseaza valorile distincte din coloana department_id
select commission_pct, first_name from employees order by commission_pct - ordonare dupa comision
order apare ultimul in interogare
order by salary DESC - ordoneaza descrescator
fara DESC - ordoneaza crescator
In WHERE nu se pot pune alias-uri. Se pot pune decat in ORDER
select first_name, last_name, department_name
from employees e, departments d
where e.department_id (+)=d.department_id
order by department_name, first_name
cu (+) dupa coloana din where care e nula pt a o afisa, afiseaza si departamentul fara nume
Nu merge (+) la mai multe coloane pt oracle
Afiseaza direct numele departamentului pt fiecare angajat (in loc de id-ul departamentului)
Varianta ANSI pt acelasi lucru
select first_name, last_name, department_name from employees full outer join departments
using (department_id)
Cu left outer inainte de joi, afiseaza ce lipseste din stanga. Cu right outer, din dreapta.
Echivalentul (+) in ambele coloane este FULL OUTER JOIN
select department_name, count (department_id)
from employees join departments
using (department_id)
group by department_name
Numara cati angajati sunt in fiecare departament. Daca se aduna, rezulta angajatii in total.
Orar semigroup #2
Oracal v.2 - de pe Academy therory
miercuri, 7 noiembrie 2012
by DlMuresan
Categories:
ionescu,
Oracle,
radu banciu
|
1 comment