Download presentation
Presentation is loading. Please wait.
1
Oracle Academy Lead Adjunct
Prof. Carmen Popescu Oracle Academy Lead Adjunct
2
Forma generala a comenzii SELECT
SELECT expresii FROM tabele WHERE conditii In clauza select pot aparea coloane, sau expresii Ordinea operatorilor: * / + - Operatorii logici: AND, OR (in aceasta ordine)
3
BETWEEN SELECT * from employees WHERE department_id BETWEEN 10 AND 30
department_id >=10 AND department_id<=30 Departamentul 20 ESTE afisat
4
IN SELECT * from employees WHERE department_id IN (10,30)
department_id=10 OR department_id=30 Departamentul 20 NU ESTE afisat
5
NULL 5+NULL => NULL La ordonare crescatoare valorile NULL sunt puse la sfarsit La ordonare descrescatoare NULL apare la inceput
6
ALIAS DE COLOANA (AS) SELECT salary+0.25*salary FROM employees
AS ”New Salary” AS New Salary => EROARE
7
ALIAS DE COLOANA (AS) SELECT first_name||’ ’||last_name AS Numele
FROM employees AS ”Numele”
8
ALIAS DE COLOANA (AS) Ghilimelele la alias sunt obligatorii cand:
Aliasul e compus din doua sau mai multe cuvinte Dorim ca aliasul sa fie scriscu litere mici
9
DESCRIBE
10
LIKE SELECT * from employees WHERE first_name LIKE ’%a%’
afiseaza toate persoanele cu un ’a’ oriunde in prenume WHERE first_name LIKE ’_ _a%’ afiseaza persoanele cu un a pe a treia pozitie din nume % - oricate caractere (inclusiv nici unul) _ - un singur caracter
11
LIKE SELECT * from employees WHERE job_title LIKE ’%\_ _ _’ ESCAPE ’\’
afiseaza persoanele pt. care in job_title, dupa caracterul _ mai exista exact doua caractere Cu clauza ESCAPE am precizat ca% sau _ precedate de \ vor fi tratate ca si caractere normale ce trebuie sa apara in text nu ca wildchar.
12
ORDER BY SELECT * FROM employees ORDER BY last_name ASC, salary DESC
SELECT first_name,salary, department_id FROM employees ORDER BY 2 Se sorteaza dupa a doua expresie din clauza SELECT, adica dupa salary
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.