Come altri hanno già detto, i join naturali sono sempre stati una cattiva idea. Cosa succede se qualcuno aggiunge una description
colonna a entrambi COURSE
e GRADE
? In ogni caso, le colonne utilizzate in un join naturale non possono essere qualificate con un alias di tabella.
create table student
( student_id integer primary key
, student_name varchar2(30) not null );
create table course
( course_id integer primary key
, course_name varchar2(30) not null );
create table grade
( student_id references student not null
, course_id references course not null
, grade varchar2(3) not null );
Domanda:
select student_id, student_name, course_id, course_name, grade
from student
natural left join grade
natural left join course;
Crea una vista:
create or replace view student_view as
select course_id, student_id, student_name, grade, course_name
from student
natural left outer join grade
natural left outer join course
union all
select course_id, student_id, student_name, grade, course_name
from course
natural left outer join grade
natural left outer join student
where student_id is null;
Continua con la tua altra domanda...