2014-11-03 74 views
1

我尝试以下操作:商店ROWID在Oracle对象类型

CREATE TYPE T_TEST AS OBJECT (
    TEST_ROWID    ROWID, 
    TEST_DATA     NUMBER(12) 
); 
/

但我得到一个错误:

ORA-24344: success with compilation error 
PLS-00530: Illegal type used for object type attribute: 'ROWID'. 

我想存储的rowid的,因为它们比索引查找速度更快。

实现上述目标的好方法是什么?从VARCHAR2投射和从VARCHAR2可能会引入尽可能多的开销与使用索引?

回答

1

您的类型定义中至少有两个错误。

Nonquoted identifiers cannot be Oracle SQL reserved words. Quoted identifiers can be reserved words, although this is not recommended.

Note: The reserved word ROWID is an exception to this rule. You cannot use the uppercase word ROWID, either quoted or nonquoted, as a column name. However, you can use the uppercase word as a quoted identifier that is not a column name, and you can use the word with one or more lowercase letters (for example, "Rowid" or "rowid") as any quoted identifier, including a column name.

所以你不能使用ROWID作为变量名。

第二个是你不能使用ROWID类型。如果你尝试,你会得到PLS-00530

据我所知有CHARTOROWID/ROWIDTOCHAR功能可能有所帮助。

+0

对不起,第一个错误是一个错字。它被称为'TEST_ROWID'和'TEST_DATA',然后我删除了TEST后缀以“改善阅读”......将调整。 – 2014-11-03 14:29:29

+0

@davor好的,你打算使用哪个索引?只是不要将函数应用于索引列 – Multisync 2014-11-03 14:31:36

+0

而不是'ROWID'我可以使用表的主键('NUMBER(20)')。 – 2014-11-03 14:34:53