我正在创建可以教授1个或多个模块的人员对象。我有一个嵌套表,其中包含模块表的引用。我还要创建另一个来显示工作人员协调的模块。有没有办法将两个不同的嵌套表命名在一起。我尝试过:
CREATE TYPE staff_typ UNDER person_typ(
staffID VARCHAR2(10),
universityEmail VARCHAR2(30),
office_ref REF office_typ,
coordintor_typ moduleProfile_typ,
teaches moduleProfile_typ)
NOT FINAL
/
CREATE TABLE staff_tab OF staff_typ;
NESTED TABLE teaches STORE AS lectures,
NESTED TABLE coordinator_typ STORE AS coordinates;
但是我得到一个包含未知语句错误的脚本。有人可以举例说明如何在这个实例中显示两个不同的嵌套表吗?
答案 0 :(得分:1)
有没有人举例说明如何在这个实例中显示两个不同的嵌套表?
CREATE TYPE varchar_ot AS OBJECT (varchar_field VARCHAR2(40));
CREATE TYPE number_ot AS OBJECT (number_field NUMBER);
CREATE TYPE varchar_ntt AS TABLE OF varchar_ot;
CREATE TYPE number_ntt AS TABLE OF number_ot;
CREATE TABLE collections
(
col_id NUMBER
, col_varchar varchar_ntt
, col_number number_ntt
)
NESTED TABLE col_varchar STORE AS col_varchar_nt
NESTED TABLE col_number STORE AS col_number_nt
;
-- table COLLECTIONS created.
INSERT INTO collections VALUES
(
1
, (varchar_ntt(varchar_ot('a'), varchar_ot('b')))
, (number_ntt (number_ot(11), number_ot(22)))
);
-- 1 rows inserted.
INSERT INTO collections VALUES
(
2
, (varchar_ntt(varchar_ot('c'), varchar_ot('d')))
, (number_ntt (number_ot(33), number_ot(44)))
);
-- 1 rows inserted.
SELECT col_id, varchar_field, number_field
FROM collections, TABLE(collections.col_varchar), TABLE(collections.col_number)
ORDER BY
3, 2, 1
;
COL_ID VARCHAR_FIELD NUMBER_FIELD
1 a 11
1 b 11
1 a 22
1 b 22
2 c 33
2 d 33
2 c 44
2 d 44
声明一个object类型的表,其中对象包含两个嵌套 表
CREATE TYPE a_varchar_ntt AS TABLE OF VARCHAR2(30);
CREATE TYPE a_number_ntt AS TABLE OF NUMBER;
CREATE TYPE var_num_ot AS OBJECT
(
col_var a_varchar_ntt
, col_num a_number_ntt
);
TYPE var_num_ntt AS TABLE OF var_num_ot;
/*
Error report:
Unknown Command
*/
如果这不是一个练习,那么你就会向错误的方向过度复杂化。