--oracle使用对象类型定义一个记录数据类型 |
CREATE TYPE name_type AS OBJECT (first_name VARCHAR2(4), last_name VARCHAR2(4)) ; |
CREATE TYPE address_type AS OBJECT (city VARCHAR2(10), street VARCHAR2(10), zip NUMBER(6)); |
CREATE TABLE worker(wid NUMBER(5) PRIMARY KEY , wname name_type ,address address_type); |
insert into worker values (1,name_type( '王' , '至远' ), address_type( '北京' , '白颐路5号' ,100084)); |
insert into worker values (2,name_type( '张' , '大年' ), address_type( '天津' , '康宁里20号' ,300072)); |
insert into worker values (3,name_type( '赵' , '力平' ), address_type( '上海' , '南京路23号' ,200092)); |
select wid 顾客编号,w.address.city 城市, w.address.street 街道,w.address.zip 邮编 from worker w ; |