时间:2021-07-01 10:21:17 帮助过:46人阅读
1,创建STRUCT类型 CREATE OR REPLACE TYPE STRUCT_TEST AS OBJECT (NAME VARCHAR2(50),TITLE VARCHAR2(30),NUM NUMBER(2)); 2,
1,创建STRUCT类型
CREATE OR REPLACE TYPE STRUCT_TEST AS OBJECT (NAME VARCHAR2(50),TITLE VARCHAR2(30),NUM NUMBER(2));
2,创建STRUCT类型的表并插入STRUCT类型数据
CREATE TABLE REF_TABLE OF STRUCT_TEST;
INSERT INTO REF_TABLE VALUES(’name’,'title’,1);
3,,创建测试表
CREATE TABLE TEST (
ID NUMBER(10,0) NOT NULL,
CONTENTR Ref STRUCT_TEST,
CONSTRAINT TEST_PK PRIMARY KEY(ID));
4,Ref类型的数据的插入
INSERT INTO TEST SELECT 1, REF(rt) FROM REF_TABLE rt
注意:必须采用这种方式插入数据!
5,Ref类型的数据的读取
SELECT DEREF(CONTENTR) AS r FROM TEST
SELECT DEREF(CONTENTR).NAME AS r FROM TEST