Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1127184
  • 博文数量: 276
  • 博客积分: 10077
  • 博客等级: 上将
  • 技术积分: 2513
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-24 20:31
文章分类

全部博文(276)

文章存档

2020年(1)

2015年(5)

2012年(2)

2011年(6)

2010年(7)

2009年(224)

2008年(31)

我的朋友

分类: Oracle

2009-04-16 08:53:44

DBLINK 访问远程自定义类型时,不同实例间自定义类型的相互访问必须使用相同的OID.

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14289/dciobjtypes.htm#sthref184

 

Assigning an Object Identifier to an Object Type

The CREATE TYPE statement has an optional keyword OID, which associates a user-specified object identifier (OID) with the type definition. It should be used by anyone who creates an object type that will be used in more than one database.

Each type has an OID. If you create an object type and do not specify an OID, Oracle generates an OID and assigns it to the type. Oracle uses the OID internally for operations pertaining to that type. Using the same OID for a type is important if you plan to share instances of the type across databases for such operations as export/import and distributed queries.

Note:

Oracle documentation often refers to the use of OIDs with rows in object tables. In CREATE TYPE with OID, an OID is assigned to the type itself. Of course, each row created in a table with a column of the specified type will also still have a row-specific OID.

For example, assume that you want to create a type named SpecialPerson and then instantiate that type in two different databases with tables named SpecialPersonTable1 and SpecialPersonTable2. The RDBMS needs to know that the SpecialPerson type is the same type in both instances, and therefore the type must be defined using the same OID in both databases. If you do not specify an OID with CREATE TYPE, a unique identifier is created automatically by the RDBMS.

The syntax for specifying an OID for an object type is:

CREATE OR REPLACE TYPE type_name OID 'oid' AS OBJECT (attribute datatype [,...]);

In the following example, the SELECT statement generates an OID, and the CREATE TYPE statement uses the OID in creating an object type named mytype. Be sure to use the SELECT statement to generate a different OID for each object type to be created, because this is the only way to guarantee that each OID is valid and globally unique.

SQLPLUS> SELECT SYS_OP_GUID() FROM DUAL; 
SYS_OP_GUID()                    
-------------------------------- 
19A57209ECB73F91E03400400B40BBE3 
1 row selected. 
 
SQLPLUS> CREATE TYPE mytype OID '19A57209ECB73F91E03400400B40BBE3'
     2> AS OBJECT (attrib1 NUMBER); 
Statement processed.
阅读(895) | 评论(0) | 转发(0) |
0

上一篇:DRIVING_SITE Hint

下一篇:LDAP

给主人留下些什么吧!~~