3.16 Transferring GeoRaster Data Between Databases
GeoRaster data can be transferred between schemas in the same database or between databases. There are several ways to transfer the GeoRaster data:
- Using GDAL or the GeoRaster ETL tool to transport the GeoRaster data between schemas in the same database or between databases. In this approach, you export the rasters from the source GeoRaster table into an exchange file format, such as GeoTIFF, and then import them into the target schema or database.
- Using the SDO_GEOR.copy or SDO_GEOR.changeFormatCopy procedures to transfer GeoRaster data between schemas in the same database. The GeoRaster objects are copied from one schema to another directly, if access is granted.
- Using Data Pump Export and Import utilities to transfer GeoRaster data between schemas in the same database or between databases. See Using Data Pump Utility to Transfer GeoRaster Data for more information.
- Using Transportable Tablespaces to transfer GeoRaster data between databases. See Using Transportable Tablespaces To Transfer GeoRaster Data for more information.
- Using Oracle Database Link to transfer GeoRaster data between databases. See Using Database Link with GeoRaster Data for more information.
It is required that in any GeoRaster database, the name of each raster
data table (RDT) must be unique and the pair of (rasterDataTable,
rasterID)
of a GeoRaster object must be unique in a database (see Raster Data Table). So, when transferring GeoRaster data between databases using
the Data Pump, the Transportable Tablespace, or Database Link approaches, conflicts
of rasterDataTable
name or rasterID
in the target
database might happen. Since changing the RDT name and making it unique will
automatically make the pair of attributes (rasterDataTable,
rasterID)
unique, it is recommended to always resolve the conflicts by
changing RDT names, as shown in the examples in the following subsections for each
of these data transfer approaches. If a GeoRaster table with the same name already
exists in the target database, it is also recommended to create a new GeoRaster
table for the transferred GeoRaster objects in the target database instead of
appending them to the existing GeoRaster table.
- Using Data Pump Utility to Transfer GeoRaster Data
- Using Transportable Tablespaces To Transfer GeoRaster Data
- Using Database Link with GeoRaster Data
Parent topic: GeoRaster Database Creation and Management
3.16.1 Using Data Pump Utility to Transfer GeoRaster Data
Data Pump Utility can be used to transfer the GeoRaster data between schemas in the same database or between databases. The following instructions are for transferring GeoRaster data between databases. But, they also apply to GeoRaster data transfer between schemas. For information about the Data Pump Export and Import utilities, see Oracle Database Utilities.
To export GeoRaster data using Data Pump, do as you would for other types
of data, but exclude the GeoRaster internal DML triggers (whose names start with
GRDMLTR_
) and the internal DDL triggers (named
SDO_GEOR_ADDL_TRIGGER
and
SDO_GEOR_BDDL_TRIGGER
). For example:
expdp herman DIRECTORY=dump_dir DUMPFILE=data.dmp
TABLES=herman.georaster_table,herman.rdt_1,herman.rdt_2
PARFILE=exclude.par
Enter password: password
In the preceding code, the exclude.par
file contains the
following:
exclude=trigger:"like 'GRDMLTR_%'"
exclude=trigger:"= 'SDO_GEOR_ADDL_TRIGGER'"
exclude=trigger:"= 'SDO_GEOR_BDDL_TRIGGER'"
The following are the general steps to import GeoRaster data (that is, the GeoRaster tables and the associated raster data tables (RDTs)) into a target database using Data Pump:
Parent topic: Transferring GeoRaster Data Between Databases
3.16.2 Using Transportable Tablespaces To Transfer GeoRaster Data
Oracle Database transportable tablespaces feature can be used to transfer GeoRaster data between databases. See Transporting Tablespaces Between Databases in Oracle Database Administrator’s Guide for more information about using the transporting tablespaces feature with spatial data.
If a tablespace to be transported contains any spatial indexes on the GeoRaster tables or raster data tables (RDTs), you may have to take some preparatory steps. See the Usage Notes for the SDO_UTIL.INITIALIZE_INDEXES_FOR_TTS procedure in Oracle Spatial Developer's Guide for more information about using the transportable tablespace feature with spatial data.
The steps explained in the following sections enable you to use transportable tablespaces to transfer GeoRaster data between databases:
Parent topic: Transferring GeoRaster Data Between Databases
3.16.2.1 Export the Tablespaces from the Source Database
To export the tablespaces from the source database for GeoRaster data migration, perform the following steps:
3.16.3 Using Database Link with GeoRaster Data
From Oracle Database Release 12.2 onwards, database link can be used to transfer GeoRaster data from one database to another.
You can execute a SQL query through a database link to access remote GeoRaster object’s attributes and binary data in the raster data tables (RDTs). The GeoRaster data manipulations provided in the GeoRaster PL/SQL packages cannot be used on the remote GeoRaster objects through a database link.
Note:
You can check the interoperability support between different releases of the database in Oracle Interoperability Support.
To transfer GeoRaster data through a database link:
- Ensure the target database schema is GeoRaster enabled. Follow the steps explained in Enabling GeoRaster at the Schema Level.
- Create the database link in the target database by executing the following SQL
statement:
CREATE PUBLIC DATABASE LINK <dblink name> CONNECT TO <username> IDENTIFIED BY <password> USING '<tnsname>';
In the preceding code:
<dblink name>:
Name of the database link<username>:
Username to connect to the source database schema where the GeoRaster table is located<password>:
Password for the source database user<tnsname>:
Source database connection name defined in thetnsname.ora
in the target database
- Identify the GeoRaster table and RDT(s) to be transferred
from the source database. Run the following query from the target
database to get the RDTs associated with the GeoRaster objects in the
GeoRaster
table.
SELECT UNIQUE t.<column_name>.rasterDataTable FROM <source_georaster_table>@<dblink_name> t;
In the preceding code,
<column_name>
is the GeoRaster column name of<source_georaster_table>
in the source database. - Transfer the RDT data from the source database to the target
database:
TheCREATE TABLE <target_rdt_table> AS (SELECT * FROM <source_rdt_table>@<dblink_name>);
<source_rdt_table>
in the preceding code is the RDT identified in step 3 (this example assumes that<source_rdt_table>
only contains the raster data that is to be transferred). If<source_rdt_table>
is unique in the target database (SDO_GEOR_ADMIN.isRDTNameUnique(‘<source_rdt_table>’)
returnstrue
), then<target_rdt_table>
should be the same as<source_rdt_table>
. Otherwise, choose a unique name for<target_rdt_table>
. - Transfer the GeoRaster objects in the GeoRaster table from
the source database to the target database. A new GeoRaster table can
be created in the target database as
follows:
CREATE TABLE <target_georaster_table> AS (SELECT * FROM <source_georaster_table>@<dblink_name>);
If the name of the new RDT created in step 4 in the target database,<target_rdt_table>
, is different from the RDT name in the source database,<source_rdt_table>
, then therasterDataTable
attribute of the GeoRaster objects in the<target_georaster_table>
needs to be updated as follows:- Connect as the schema user to find out
the GeoRaster DML trigger name on the GeoRaster
table:
SELECT trigger_name FROM user_triggers WHERE table_name = ‘<target_georaster_table>’ AND trigger_name LIKE 'GRDMLTR_%';
In the preceding code,
<target_georaster_table>
is the GeoRaster table name in the target database - Connect as DBA and disable the GeoRaster
DML
trigger:
ALTER TRIGGER <owner>.<trigger_name> DISABLE;
- Connect as the schema user and update the
rasterDataTable
attribute of the GeoRaster object:UPDATE <target_georaster_table> t SET t.<column_name>.rasterDataTable = ‘<target_rdt_table>’ WHERE t.<column_name>.rasterDataTable=’<source_rdt_table>’;
In the preceding code,
<source_rdt_table>
and<target_rdt_table>
are the table names used in step 4.<column_name>
is the GeoRaster column name in the<target_georaster_table>
. - Connect as DBA and enable the GeoRaster
DML
trigger:
ALTER TRIGGER <owner>.<trigger_name> ENABLE;
- Connect as the schema user to find out
the GeoRaster DML trigger name on the GeoRaster
table:
- Connect as the schema user and register the transferred
GeoRaster objects in the target
database:
EXECUTE SDO_GEOR_ADMIN.registerGeorasterObjects;
Database link can also be used in the Data Pump import utility to transfer GeoRaster data directly from the source database to the target database. See Using Data Pump Utility to Transfer GeoRaster Data about how to use Data Pump import utility to transfer GeoRaster data.
Parent topic: Transferring GeoRaster Data Between Databases