我把类型和子类型定义为
Create or replace type Component_ty as object (
Code VARCHAR(10),
Component_Description VARCHAR(100),
Component_Type VARCHAR(10))
NOT FINAL;
Create or replace type External_Component_ty under Component_ty(
External_Company REF External_Company_ty);
其中External_company_ty定义为
Create or replace type External_Company_ty as object (
VAT VARCHAR(15),
Company_Name VARCHAR(20),
Component_code VARCHAR(5),
Address External_Company_address_ty)
NOT FINAL;
table是
create table Component of component_ty(
Code Primary Key,
Component_Description NOT NULL,
Component_Type NOT NULL);
create table External_Company of external_company_ty (
VAT Primary Key,
Company_Name NOT NULL,
Component_Code NOT NULL,
Address NOT NULL);
我可以向这个查询添加什么,以便显示另一列,其中external_company.component_code引用了该特定组件??
select c.*, treat(value(c) as external_component_ty).external_company as external_company FROM component c
1条答案
按热度按时间ac1kyiln1#
只需选择
component_code
属性:对于示例数据(忽略
address
列,因为您尚未定义该对象):其输出:
| 代码|组件描述|组件类型|外部公司代码|
| --------------|--------------|--------------|--------------|
| A|ABC|XYZ|CodeA|
fiddle