今天在對視圖進行查詢時,查詢中帶有rowid字段,結果報錯:
做了兩張簡單的表測試:STUDENT,CLASS
1、創建表
create table STUDENT
(
sno NUMBER,
sname VARCHAR2(32)
)
-----------------------------------
create table CLASS
(
cno NUMBER not null,
sno NUMBER not null,
cname VARCHAR2(32)
)
2、創建一個視圖
create or replace view stu_class_v as
select s.sno, s.sname, c.cno, c.cname
from student s, stu_class c
where s.sno = c.sno
3、對視圖進行查詢
select rowid, sno From stu_class_v
這時就會報出如上錯誤
因為新建的兩張表,主表和從表都沒有設置對應的主鍵,這裡對STUDENT表添加主鍵,再對視圖進行查詢,查詢正常