嗨,伙计们,我有以下两个 Oracle 对象:
CREATE OR REPLACE TYPE car AS OBJECT(
name VARCHAR( 80 )
) NOT FINAL;
而且,还有另一个对象:
CREATE OR REPLACE TYPE truck UNDER car (
doors NUMBER,
seats NUMBER
);
还有下表:
CREATE TABLE vehicles (
id NUMBER NOT NULL,
vehicle car,
PRIMARY KEY (id)
);
这是一些数据:
INSERT INTO vehicles ( id, vehicle ) VALUES ( 1, truck( 'ford', 4, 4 ) );
INSERT INTO vehicles ( id, vehicle ) VALUES ( 2, truck( 'toyota', 4, 5 ) );
最后,我的问题是: 如何从车辆表列中仅选择门数和座位数?
我尝试了以下但它不起作用:
SELECT v.vehicle.doors AS doors AS seats FROM vehicles v;
我收到以下错误:
ORA-00904: "V"."VEHICLE"."DOORS": invalid identifier
我唯一能得到的没有任何错误的参数是来自汽车对象的参数。
仅供参考,我在 CentOS 6.2 上使用 Oracle 11g
干杯,博扬