我有家庭作业的问题,我被困在B部分。我已经完成了A部分,没有问题,但是一直有错误。
定义一个名为phone_type的用户定义对象类型数据类型,其属性为COUNTRY_CODE、AREA_CODE和PHONE_NUMBER.
B.Define是用户定义的VARRAY数据类型,名为Phone_List_type,大小为phone_type类型的3。
回答A:
CREATE TYPE phone_type AS OBJECT (country_code Number, area_code Number, phone_number Number);结果:编译phone_type类型
回答B。
CREATE TYPE phone_list_type AS VARRAY(3) of phone_type;错误消息:已在存在的对象中使用名称
发布于 2019-07-07 07:22:21
在创建phone_list_type之前尝试删除它。当您已经编译了定义类型的代码并想要更改它(代码/定义)时,问题就出现了。
SQL> CREATE TYPE phone_type AS OBJECT (
2 country_code Number
3 , area_code Number
4 , phone_number Number
5 );
6 /
Type PHONE_TYPE compiled
SQL> CREATE TYPE phone_list_type AS VARRAY(3) of phone_type;
2 /
Type PHONE_LIST_TYPE compiled
SQL> CREATE TYPE phone_list_type AS VARRAY(3) of phone_type;
2 /
Error starting at line : 1 in command -
CREATE TYPE phone_list_type AS VARRAY(3) of phone_type;
Error report -
ORA-00955: name is already used by an existing object
00955. 00000 - "name is already used by an existing object"
*Cause:
*Action:Oracle不只是“覆盖”现有的类型定义。现在,您可以删除类型并使用您的新定义:
SQL> drop type phone_list_type;
Type PHONE_LIST_TYPE dropped.
SQL> CREATE TYPE phone_list_type AS VARRAY(3) of phone_type;
2 /
Type PHONE_LIST_TYPE compiled如果跌落型..。不工作,也可以强制执行(请参阅文档)。
发布于 2019-07-07 13:51:39
使用CREATE OR REPLACE TYPE而不是CREATE TYPE
CREATE OR REPLACE TYPE phone_list_type AS VARRAY(3) of phone_type;https://stackoverflow.com/questions/56918688
复制相似问题