概念
In this release, support for operations over database links for LOB-based data types, such as CLOB, BLOB and XMLType, is available.
This support enables operations on LOB-based data types across pluggable databases (PDBs) in an Oracle Multitenant environment.
在這個版本中,支持基於數據庫鏈接的LOB-based數據類型的操作,比如CLOB、BLOB和XMLType。
這種支持支持在Oracle多租戶環境中跨可插入數據庫(PDBs)上的基於LOB-based數據類型的操作。
You can work with LOB data in remote tables is the following ways:
• Directly referencing LOB columns in remote tables (Remote LOB Columns) accessed using a database link.
• Selecting remote LOB columns into a local LOB locator variable (Remote locator)
您可以在遠程表中使用LOB數據,方法如下:
•直接引用遠程表中的LOB列(遠程LOB列),使用數據庫鏈接訪問。
•選擇遠程LOB列到本地LOB定位器變量(遠程定位器)
實驗
1) 在本機windows tnsname.ora 配置連接11g,12c 的服務
--Oracle 11g
cndba1.69 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.69)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cndba)
)
)
--Oracle 12c
pdb76 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.76)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdbcndba)
)
)
2)在本地服務器創建指向11g,12c 的DBlink
create public database link pdb_76
connect to test identified by test
using 'pdb76';
create public database link CNDBA69
connect to test identified by test
using 'cndba1.69';
3) 在11g,12c 數據庫環境中創建表及CLOB 字段
[oracle@localhost ~]$ sqlplus test/test
SQL*Plus: Release 11.2.0.4.0 Production on Mon Aug 14 22:15:43 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table t1 (x clob );
Table created.
SQL> insert into t1 values('yyy');
1 row created.
SQL> commit;
Commit complete.
[oracle@host1 ~]$ sqlplus /nolog
SQL*Plus: Release 12.2.0.1.0 Production on Mon Aug 14 22:55:10 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1593835520 bytes
Fixed Size 8793256 bytes
Variable Size 1023411032 bytes
Database Buffers 553648128 bytes
Redo Buffers 7983104 bytes
Database mounted.
Database opened.
SQL> alter session set container=pdbcndba;
Session altered.
SQL> startup
Pluggable Database opened.
SQL> conn test/test@pdbcndba
Connected.
SQL> create table t2(x clob );
Table created.
SQL> insert into t2 values('yyy');
1 row created.
SQL> commit;
Commit complete.
4) 查看數據庫時,11g LOB 對象不支持分布式LOB操作,12C 可以
SQL> select * from t1@cndba69;
ERROR:
ORA-65510: 12.2 版本之前的數據庫不支持分布式 LOB 操作。
未選定行
SQL> select * from t2@pdb_76;
X
--------------------------------------------------------------------------------
yyy
5) Create table as select or insert as select
只有獨立的LOB列在選擇列表中被允許以下列方式構造語句
SQL> CREATE TABLE t3 AS SELECT * FROM t2@pdb_76;
表已創建。
SQL> INSERT INTO t3 SELECT * FROM t2@pdb_76;
已創建 1 行。
SQL> UPDATE t3 SET x = (SELECT x FROM t2@pdb_76);
已更新 2 行。
SQL> INSERT INTO t2@pdb_76 SELECT * FROM t3;
已創建 2 行。
SQL> UPDATE t2@pdb_76 SET x ='zzz';
已更新 3 行。
SQL> DELETE FROM t2@pdb_76 where rownum<=1;
已刪除 1 行。
6)Functions on remote LOBs returning scalars
具有LOB參數並返回標量數據類型的SQL和PL/SQL函數得到支持。不支持其他SQL函數和DBMS_LOB api使用遠程LOB列。例如,支持以下語句:
SQL> CREATE TABLE tab2 AS SELECT LENGTH(x) len FROM t2@pdb_76;
表已創建。
但是,不支持下面的語句,因為DBMS_LOB。子串函數返回一個LOB:
SQL> CREATE TABLE tab AS SELECT DBMS_LOB.SUBSTR(x) len from t2@pdb_76;
CREATE TABLE tab AS SELECT DBMS_LOB.SUBSTR(x) len from t2@pdb_76
*
第 1 行出現錯誤:
ORA-22992: 無法使用從遠程表選擇的 LOB 定位符
7)您可以從遠程表中選擇一個持久的LOB定位器到本地變量,這可以在PL/SQL或OCI中完成
參考鏈接:(文檔非常好)
http://docs.oracle.com/database/122/NEWFT/new-features.htm#GUID-8B121B03-481B-4596-9855-1FBF68532095
http://docs.oracle.com/database/122/ADLOB/distributed-LOBs.htm#ADLOB-GUID-7E450E86-3E4E-4714-A164-FD36B93722F6