CREATE TYPE goods_type AS OBJECT( |
gno NUMBER(3), |
gname varchar2(20), |
price number(6,2) |
); |
/ |
CREATE TABLE goods OF goods_type |
( constraint p1 primary key (gno)) ; |
INSERT INTO goods VALUES (101, '电视机' ,2900); |
INSERT INTO goods VALUES (102, '洗衣机' ,1500); |
CREATE TYPE order_type AS OBJECT( |
orderid NUMBER(3), |
customer REF cust_type, |
orderdate DATE , |
qty NUMBER(5), |
gno NUMBER(3) |
); |
/ |
CREATE TABLE orders OF order_type |
( FOREIGN KEY (gno) REFERENCES goods(gno) ) ; |
/ |