我不断从下面的输入中收到以下错误“列不明确定义”。我正在使用 Oracle SQL Developer。
我目前在学校,这是我的作业之一。话虽如此,我非常缺乏经验,很可能需要一个“孩子般的”解释。作业指出,“创建一个视图以列出所有可供租借的电影。该视图应包括标题、类别描述(不是类别代码)、公司、导演、演员、商店、副本、类型。” 我想我可能加入了太多的桌子?!?或者,显然,只是没有正确执行。任何帮助将不胜感激。
create view AvailableMovies as
select m.title, mcat.description, comp.company_name, d.director_name,
act.actor_name, mrs.store_name, mrl.available_for_rent, mrl.type_distributed
from companies comp
join directors d
on comp.company_id = d.company_id
join movie_directors mdir
on d.director_id = mdir.director_id
join actor_in_movies aim
on mdir.movie_id = aim.movie_id
join actors act
on aim.actor_id = act.actor_id
join actor_in_movies aim
on act.actor_id = aim.actor_id
join order_items oi
on aim.movie_id = oi.movie_id
join orders o
on oi.order_id = o.order_id
join movie_rental_stores mrs
on o.store_id = mrs.store_id
join movie_rent_list mrl
on mrs.store_id = mrl.store_id
join movies m
on mrl.movie_id = m.movie_id
join movie_categories mcat
on m.category_code = mcat.category_code
order by m.title;
如果这有帮助,以下是我作业中的所有表格:
create table companies(
company_id number(3),
company_name varchar2(30) not null,
description varchar2(100)
);
create table movie_categories(
category_code char(3) not null,
description varchar2(50)
);
create table movies (
movie_id number(5),
title varchar2(30) not null,
category_code char(3) not null,
description varchar2(500),
released_by number(3) not null,
released_on date not null
);
create table directors(
director_id number(5),
director_name varchar2(30) not null,
company_id number(3) not null
);
create table movie_directors(
movie_director_id number(5),
movie_id number(5) not null,
director_id number(5) not null
);
create table awards(
award_id number(4),
award varchar2(30) not null,
award_description varchar2(100)
);
create table movie_awards(
movie_award_id number(5),
movie_id number(5) not null,
award_id number(4) not null,
award_date date
);
create table actors(
actor_id number(5),
actor_name varchar2(30) not null,
gender char(1),
contact varchar2(20)
);
create table actor_in_movies(
movie_actor_id number(5),
movie_id number(5) not null,
actor_id number(5) not null
);
create table movie_distributors(
distributor_id number(3),
distributor_name varchar2(30) not null,
location varchar2(40),
contact varchar2(40)
);
create table distributed_movie_list(
distribution_id number(8),
movie_id number(5) not null,
distributor_id number(3) not null,
distribute_type varchar2(10),
inventory_quantity number(3) default 0,
unit_price number(8,2)
);
create table movie_rental_stores(
store_id number(4),
store_name varchar2(30) not null,
store_location varchar2(50)
);
create table orders(
order_id number(8),
store_id number(4) not null,
description varchar2(30),
total_items number(3),
total_payment number(8,2),
tax number(6,2),
order_status varchar2(2),
ordering_date date,
order_completed_date date
);
create table order_items(
item_id number(10),
order_id number(8) not null,
distribution_id number(8) not null,
movie_id number(5) not null,
number_of_items number(3),
item_unit_price number(5,2),
item_sub_total number(10,2)
);
create table movie_rent_list(
title_id number(5),
movie_id number(5) not null,
store_id number(4) not null,
number_in_store number(2),
available_for_rent char(1),
rent_unit_price number(5,2),
type_distributed varchar2(10),
overdue_unit_fee number(5,2)
);
create table movie_copies(
copy_id number(5),
title_id number(5) not null,
available char(1) default 'Y'
);
create table customers(
customer_id number(5),
store_id number(4) not null,
firstname varchar2(20),
lastname varchar2(20),
gender char(1),
address varchar2(50),
card_approved char(1),
card_approved_date date,
phone_number varchar2(10),
card_number number(10),
rent_limit number(2),
overdue_notified char(1)
);
create table movie_rent_records(
rent_record_id number(8),
customer_id number(5) not null,
copy_id number(5) not null,
rented_date date,
returned_date date,
rent_fee number(5,2),
overdue_fee number(5,2),
overdue_days number(2)
);