创建视图内部联接错误

时间:2013-12-04 03:21:05

标签: oracle oracle11g

我正在创建一个视图并使用内部联接并收到以下错误:

ORA-00904: "B"."CUSTOMERNO": invalid identifier

这是我正在使用的代码来创建视图和内部联接

CREATE VIEW RentalInfoOct
(branch_no, branch_name, customer_no)
AS
SELECT b.branchNo, b.branchName, b.customerNo, c.customerNo
FROM branch b
INNER JOIN 
customer c
ON b.customerNo = c.customerNo

以下是create table命令。

CREATE TABLE Branch
(
branchNo    SMALLINT    NOT NULL,
branchName  VARCHAR(20) NOT NULL,
branchAddress   VARCHAR(40) NOT NULL,
PRIMARY KEY (BranchNo)
);  

CREATE TABLE Customer
(
customerNo      SMALLINT    NOT NULL,
customerName        VARCHAR(15) NOT NULL,
customerAddress     VARCHAR(40) NOT NULL,
customerTel         VARCHAR(10),
PRIMARY KEY (CustomerNo)
);

1 个答案:

答案 0 :(得分:0)

CREATE VIEW RentalInfoOct
(branch_no, branch_name, customer_no)
AS
SELECT b.branchNo, b.branchName, b.customerNo, c.customerNo

为视图指定3列,但在SELECT

中选择4列