[20210723]Database link and user defined datatypes.txt
--//如何通过db link访问用户定义类型.按照链接做测试.
https://laurentschneider.com/wordpress/2021/07/database-link-and-user-defined-datatypes.html
1.环境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.测试:
create type tt as object (x number);
/
create table t (x tt);
insert into t values (tt(1));
commit;
SCOTT@book> select t.x.x from t t;
X.X
----------
1
--//OK,本地访问没有问题.
CREATE PUBLIC DATABASE LINK LOOPBACK USING 'localhost:1521/book';
SCOTT@book> select t.x.x from t@LOOPBACK t;
X.X
----------
1
--//采用本地loopback测试不出来.
3.继续:
CREATE PUBLIC DATABASE LINK L78
CONNECT TO SCOTT
IDENTIFIED BY <Password>
USING '192.168.100.78:1521/book';
SCOTT@test> select sysdate from dual@l78;
SYSDATE
-------------------
2021-07-23 09:47:24
--//OK.
SCOTT@test> select t.x.x from t@L78 t;
select t.x.x from t@L78 t
*
ERROR at line 1:
ORA-22804: remote operations not permitted on object tables or user-defined type columns
SCOTT@test> select type_name,TYPE_OID from user_types@L78;
TYPE_NAME TYPE_OID
------------------------------ --------------------------------
TT C7C175F2E6ED5C33E0534E64A8C010B5
SCOTT@test> create type tt oid 'C7C175F2E6ED5C33E0534E64A8C010B5' as object(x number)
2 /
Type created.
--//视乎建立的type不指定可以唯一.
SCOTT@test> select t.x.x from t@L78 t;
X.X
----------
1
--//感觉type的东西很少用,做一个记录.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2782847/ ,如需转载,请注明出处,否则将追究法律责任。