Oracle Alter对象?

时间:2016-09-13 19:17:57

标签: sql oracle ddl

我尝试使用以下命令修改oracle对象内的number(7,0)属性:

alter type myObjectFormat
  modify ATTRIBUTE (
    A NUMBER(7,2)) CASCADE FORCE;

ERROR:

Error report -
SQL Error: ORA-06545: PL/SQL: compilation error - compilation aborted
ORA-06550: line 10, column 32:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   exceptions
ORA-06550: line 0, column 0:
PLS-00565: MYOBJECTFORMAT must be completed as a potential REF target (object type)
06545. 00000 -  "PL/SQL: compilation error - compilation aborted"
*Cause:    A pl/sql compilation error occurred and the compilation was
           aborted completely without the compilation unit being written
           out to the backing store.  Unlike ora-06541, the user will always
           see this error along with the accompaning PLS-nnnnn error messages.
*Action:   See accompanying PLS-nnnnn error messages.

我的目标如下:

create or replace type myObjectFormat
as object (
  A   number(7,0)
);

使用函数(显然只是重新创建错误的一个例子):

CREATE OR REPLACE FUNCTION STACKOVERFLOW RETURN MYOBJECTFORMAT AS 
BEGIN
  RETURN NULL;
END STACKOVERFLOW;

我尝试手动更改对象中的数据类型,但收到错误Error(1,1): ORA-02303: can't drop or replace a type with type or table dependents. SQLDev advises setting "Drop Type Force" preference错误消息。 " easy"此时要做的是使用此对象删除函数,进行更改,然后重新创建函数。 " easy"随着这个数据库的增长,这种方式不可行。

Oracle参考资料:

Type Evolution

ALTER TYPE Statement

我更喜欢使用alter type语句,只知道我的语法是否关闭?在我看来,我的FORCE命令位于错误的位置。

1 个答案:

答案 0 :(得分:1)

您似乎错过了exceptions_clause

dependent_handling_clause :: =

enter image description here exceptions_clause :: =

enter image description here

  

如果希望数据库忽略依赖表和索引中的错误并记录指定异常表中的所有错误,请指定FORCE。必须已通过执行DBMS_UTILITY.CREATE_ALTER_TYPE_ERROR_TABLE过程创建了异常表。

意思是,如果你有FORCE,那么你需要说出你希望流向哪个表。