Vous êtes sur la page 1sur 3

select * from employees;

select * from departments;

insert into departments values(50,'Marketing','California');

commit;
-- Cross join
select
Employee_ID,Employee_Name,Job,Location,Department_Name,departments.DEPARTMENT_ID
from departments,employees;

select * from test_100;


select * from students;

select * from test_100,students;

-- inner join and equi join


select
Employee_ID,Employee_Name,Job,Location,Department_Name,departments.DEPARTMENT_ID
from departments,employees
where departments.department_id=employees.department_id
and departments.department_id=50;

select
Employee_ID,Employee_Name,Job,Location,Department_Name,departments.DEPARTMENT_ID
from departments,employees
where departments.department_id=employees.department_id
and departments.department_id=20;

select Employee_ID ID,Employee_Name Name,Job,Location,Department_Name


Dep,E.DEPARTMENT_ID -- column alising
from departments D,employees E -- Table alising
where D.department_id=E.department_id
and D.department_id=20;

select Employee_ID as ID,Employee_Name as Name,Job,Location,Department_Name as


Dep,E.DEPARTMENT_ID -- column alising
from departments D,employees E -- Table alising
where D.department_id=E.department_id
and D.department_id=20;

-- inner join

select Employee_ID ID,Employee_Name Name,Job,Location,Department_Name


Dep,E.DEPARTMENT_ID -- column alising
from departments D inner join employees E on D.DEPARTMENT_ID=E.DEPARTMENT_ID
where D.DEPARTMENT_ID=20;

select Employee_ID ID,Employee_Name Name,Job,Location,Department_Name


Dep,E.DEPARTMENT_ID -- column alising
from departments D inner join employees E on D.DEPARTMENT_ID=E.DEPARTMENT_ID;
--where D.DEPARTMENT_ID=20;
-- outer join
-- Right outer join

select Employee_ID ID,Employee_Name Name,Job,Location,Department_Name


Dep,E.DEPARTMENT_ID -- column alising
from departments D right outer join employees E on
D.DEPARTMENT_ID=E.DEPARTMENT_ID;

select Employee_ID ID,Employee_Name Name,Job,Location,Department_Name


Dep,D.DEPARTMENT_ID -- column alising
from departments D left outer join employees E on D.DEPARTMENT_ID=E.DEPARTMENT_ID;

select Employee_ID ID,Employee_Name Name,Job,Location,Department_Name


Dep,D.DEPARTMENT_ID -- column alising
from departments D full outer join employees E on D.DEPARTMENT_ID=E.DEPARTMENT_ID;

select * from employees;

update employees
set department_id=null
where employee_id in (1107,1113);
commit;

select * from employees;

-- SET

create table set_A


(
id number(2),
val varchar(20)
);
insert into set_A values(10,'A');
insert into set_A values(20,'B');
insert into set_A values(30,'C');
insert into set_A values(40,'D');
commit;

create table set_B


(
id number(2),
val varchar(20)
);

insert into set_B values(10,'A');


insert into set_B values(50,'E');
insert into set_B values(60,'F');
insert into set_B values(70,'G');
commit;

select * from set_A;

select * from set_B;

delete from set_A where id in(10,50,60,70);


commit;

select id,val from set_A


union
select id,val from set_b;

select id,val from set_A


intersect
select id,val from set_b;

select id,val from set_A


minus
select id,val from set_b;

select id,val from set_B


minus
select id,val from set_A;

select id,val from set_A


union all
select id,val from set_b;

Vous aimerez peut-être aussi