我正在尝试使用表格trip
,guide
和reservation
来制作规范化表格。我收到错误“ORA-00933:SQL命令未正确结束。”
我不确定ALTER TABLE有什么问题。
SELECT trip.TRIP_ID, trip.State, trip.Max_grp_size, trip.type, trip.season, guide.Guide_num, guide.last_name, guide.First_name, guide.address, guide.city, guide.Hire_date, trip_guides.guide_num, reservations.trip_price
FROM trip
JOIN trip_guides ON trip.TRIP_ID = trip_guides.trip_id
JOIN Guide ON trip_guides.guide_num = guide.Guide_num
ALTER TABLE trip ADD (price_trip CHAR)
JOIN reservations ON trip.price_trip = reservations.trip_price
ORDER BY trip.trip_ID;
答案 0 :(得分:0)
听起来你想要的是一个"创建表... AS(SELECT ...)"陈述的类型。基本上根据SQL语句的结果集创建一个新表。
这看起来像是:
CREATE TABLE your_1st_level_normalized_table AS
(
SELECT trip.TRIP_ID,
trip.STATE,
trip.Max_grp_size,
trip.type,
trip.season,
guide.Guide_num,
guide.last_name,
guide.First_name,
guide.address,
guide.city,
guide.Hire_date,
trip_guides.guide_num,
reservations.trip_price,
NULL as PRICE_TRIP /*new field in the new table set to NULL*/
FROM trip
JOIN trip_guides ON trip.TRIP_ID = trip_guides.trip_id
JOIN Guide ON trip_guides.guide_num = guide.Guide_num
JOIN reservations ON trip.price_trip = reservations.trip_price
);
我已删除了ORDER BY,因为此声明中不允许这样做。