Friday, October 8, 2010

Create Oracle Materialized Views on CLOB/BLOB via DB Links

If you try to create a materialized view on a LOB column via a database link, for example,
CREATE MATERIALIZED VIEW myview
AS
SELECT LobCol FROM tbl@another_server

Oracle will throw you the following error,
ORA-22992: cannot use LOB locators selected from remote tables
22992. 00000 – "cannot use LOB locators selected from remote tables"
*Cause: A remote LOB column cannot be referenced.
*Action: Remove references to LOBs in remote tables.

Here is a simple workaround.
First, create a view on the remote server:
create or replace view remoteview
as
select LobCol from tbl

Then, create your materialized view against the view:
create materialized view myview
as
select * from remoteview@another_server

3 comments:

Sophearin said...

Does the view store the data?

Jing said...

Yes, materialized views physically store data.

Sophearin said...

How to CREATE MATERIALIZED VIEW LOG ON ... from Views stored on the Master DB?