【发布时间】:2014-01-06 01:10:36
【问题描述】:
我的作业有问题。我有以下类型定义:
-- Type definitions
CREATE OR REPLACE TYPE languages_table_t AS TABLE of VARCHAR2(20);
/
CREATE OR REPLACE TYPE phones_table_t AS TABLE of NUMBER;
/
CREATE OR REPLACE TYPE tourist_t AS OBJECT (
-- ...
-- some simple attrubutes
-- one attribute of user defined type
-- more simple attrubutes
-- ...
) NOT FINAL;
/
CREATE OR REPLACE TYPE guide_t UNDER tourist_t (
languages languages_table_t,
phones phones_table_t
);
/
-- All types are created successfully
-- table definitions:
CREATE TABLE Tourist OF tourist_t (
-- all simple attributes with nullity constraints
CONSTRAINT PK_TOURIST PRIMARY KEY (username),
) NESTED TABLE the_UDT_attr STORE AS the_user_defined_type;
-- Created successfully
CREATE TABLE Guide OF guide_t (
CONSTRAINT PK_GUIDE PRIMARY KEY (username)
) NESTED TABLE languages STORE AS guide_languages
NESTED TABLE phones STORE AS guide_phones;
-- returns mystic error
运行最后一条创建指令时,出现以下错误:
CREATE TABLE Guide OF guide_t (
*
ERROR at line 1:
ORA-22913: must specify table name for nested table column or attribute
我已经搜索过这个错误,但它似乎对我的定义过于具体,我找不到解决方法。请,任何帮助将不胜感激。我需要一个关于如何解决这类错误、如何解决它们或在哪里阅读它的想法。
sqlplus的版本是:
SQL> SELECT * FROM V$VERSION;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
如果您需要任何其他信息来帮助我,请提出,我会更新问题。
谢谢!
【问题讨论】:
-
在我向
tourist_t添加了一个真实的列之后,您的示例对我有用。你确定所有类型都创建成功了吗?某些 IDE,例如 PL/SQL Developer,将执行create type语句,但不会警告您出现异常。 -
@jonearles:是的,我确信它们已成功创建。我没有使用 IDE,而是使用符号
@script.sql在 sqlplus CLI 中加载脚本。到目前为止,我认为这可能是一些旧运行的遗留物,也许我不是在干净的环境中工作,但我对 oracle 管理不熟悉。有没有办法清理会话并在干净的环境中重新开始? -
由于您的脚本没有架构名称,因此您应该能够在任何数据库上以任何用户身份运行它们。要重新开始,您可以运行如下脚本:
drop table guide; drop type guide_t; drop type tourist_t; drop type phones_table_t; drop type languages_table_t;。使用您的代码,tourist_t应该会以PLS-00589: no attributes found in object type "TOURIST_T"失败。 -
@jonearles:另外,在我的脚本中,
tourist_t有很多列。没有的是 tableguide,它只有嵌套的表格属性。你可以在my repo(西班牙语)中看到真正的脚本
标签: sql oracle sqlplus object-relational-model