gpt4 book ai didi

oracle - 如何创建包含对象类型嵌套表的 Oracle 表?

转载 作者:行者123 更新时间:2023-12-02 07:13:13 26 4
gpt4 key购买 nike

我有一个高度嵌套的对象类型结构,它允许我以树状方式保存数据。

我现在想创建一个表来缓存这些对象,但我很难创建表。我怀疑我的问题是多个嵌套级别,但不知道如何解决。

CREATE TYPE STEP_OBJ AS OBJECT (
ID VARCHAR2(20),
OTHER_FIELDS VARCHAR2(100));
/

CREATE TYPE STEP_TAB_OBJ AS TABLE OF STEP_OBJ;
/

CREATE TYPE TREE_OBJ AS OBJECT (
STEPS STEP_TAB_OBJ,
COMPLETE VARCHAR2(1));
/

CREATE TYPE TABLE_OF_TREE_OBJ AS TABLE OF TREE_OBJ;
/

CREATE TABLE TREE_TABLE_CACHE (
HANDLE VARCHAR2(20),
TABLE_OF_TREES TABLE_OF_TREE_OBJ)
NESTED TABLE TABLE_OF_TREES STORE AS TREE_TABLE_CACHE_OBJS;
/

CREATE TABLE TREE_TABLE_CACHE (
*
ERROR at line 1:
ORA-02320: failure in creating storage table for nested table column TABLE_OF_TREES
ORA-22913: must specify table name for nested table column or attribute

Oracle 11g。

最佳答案

您需要为内部集合指定一个存储子句。语法只是将嵌套集合的子句括在括号中,如下所示:

SQL> CREATE TABLE TREE_TABLE_CACHE (
2 HANDLE VARCHAR2(20),
3 TABLE_OF_TREES TABLE_OF_TREE_OBJ)
4 NESTED TABLE TABLE_OF_TREES STORE AS TREE_TABLE_CACHE_OBJS
5 ( NESTED TABLE STEPS STORE AS TREE_TABLE_CACHE_STEPS)
8 /

Table created.

SQL>

关于oracle - 如何创建包含对象类型嵌套表的 Oracle 表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9454933/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com