错误报告 - ORA-25155:NATURAL 连接中使用的列不能有限定符 25155.00000 - “NATURAL 连接中使用的列不能有限定符" [英] Error report - ORA-25155: column used in NATURAL join cannot have qualifier 25155. 00000 - "column used in NATURAL join cannot have qualifier"
问题描述
当我运行这条线时,它给了我下面的错误.
CREATE VIEW student_view ASSELECT Student.*, Course.*, Grade.*发件人(学生自然左外连接等级自然左外连接课程)联合所有SELECT Student.*, Course.*, Grade.*从(当然自然左外连接等级自然左外连接学生)WHERE Student.StudentID 为 NULL
<块引用>
*原因:用于命名连接的列(自然连接或带有 USING 子句的连接)不能有显式限定符.
*操作:删除限定符
正如其他人提到的,自然连接一直是个坏主意.如果有人将 description
列添加到 COURSE
和 GRADE
会怎样?无论如何,自然连接中使用的列不能用表别名进行限定.
创建表student( student_id 整数主键, student_name varchar2(30) not null );创建表课程( course_id 整数主键, course_name varchar2(30) not null );创建表等级( student_id 引用 student 不为空, course_id 引用 course not null, 等级 varchar2(3) 不为 null );
查询:
选择student_id、student_name、course_id、course_name、成绩来自学生自然左连接等级自然左连接课程;
创建视图:
创建或替换视图 student_view 为选择 course_id、student_id、student_name、成绩、course_name来自学生自然左外连接等级自然左外连接课程联合所有选择 course_id、student_id、student_name、成绩、course_name从课程自然左外连接等级自然左外加入学生其中 student_id 为空;
继续您的其他问题...
When I am running this lines, it is giving me the error below.
CREATE VIEW student_view AS
SELECT Student.*, Course.*, Grade.*
FROM (Student
NATURAL LEFT OUTER JOIN Grade
NATURAL LEFT OUTER JOIN Course)
UNION ALL
SELECT Student.*, Course.*, Grade.*
FROM (Course
NATURAL LEFT OUTER JOIN Grade
NATURAL LEFT OUTER JOIN Student)
WHERE Student.StudentID is NULL
*Cause: Columns that are used for a named-join (either a NATURAL join or a join with a USING clause) cannot have an explicit qualifier.
*Action: Remove the qualifier
As others have mentioned, natural joins have always been a bad idea. What if someone adds a description
column to both COURSE
and GRADE
? Anyway, columns used in a natural join can't be qualified with a table alias.
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 );
Query:
select student_id, student_name, course_id, course_name, grade
from student
natural left join grade
natural left join course;
Create a view:
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;
Continued on your other question...
这篇关于错误报告 - ORA-25155:NATURAL 连接中使用的列不能有限定符 25155.00000 - “NATURAL 连接中使用的列不能有限定符"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!