Set up an Oracle destination¶
The Replicator Service writes to an Oracle database through an ODBC driver on the Stelo VM. It creates the destination tables and their indexes, loads baselines and snapshots, and applies incremental changes with SQL.
Supported configurations¶
| Supported | |
|---|---|
| Oracle | Oracle Database, including a pluggable database (PDB) of a multitenant container database. Oracle Autonomous Database through the SQDR bundled Oracle driver with SSL/TLS (see Connection strings). Tibero is handled as Oracle. For other cloud services, ask Stelo Support. |
| Driver on the Stelo VM | SQDR bundled Oracle driver (installed and licensed with SQDR), or the Oracle ODBC driver of Oracle Instant Client (Windows). See Databases. |
| Snapshot replication | Yes. |
| Incremental replication | Yes, from any source with a Capture Agent. |
| Apply methods | Batch, Merge and Sequence (see Choosing the apply method). |
| Authentication | Remote Credentials: an Oracle database user and its password. |
| Encryption | SSL/TLS with the bundled driver (EM=1 and a key store), or the Oracle Wallet configured in sqlnet.ora for the Oracle ODBC driver. See Connection strings. |
Docker
The SQDR container includes the SQDR bundled Oracle driver, not the Oracle ODBC driver (see ODBC drivers in the container).
Prepare the database¶
The database administrator creates the user the Replicator Service connects as, with the privileges for the SQL it runs (see What the Replicator Service runs on the database). Stelo recommends the simplest setup: a user that owns the schema the destination tables go into, since an Oracle user can create, change, empty, index and drop the tables in its own schema without any other grant.
Create the user¶
Run as a database administrator (for example SYSTEM), connected to the PDB if the database is a container database:
CREATE USER sqdruser IDENTIFIED BY "mypassword"
DEFAULT TABLESPACE users
QUOTA UNLIMITED ON users;
GRANT CREATE SESSION, CREATE TABLE TO sqdruser;
Replace sqdruser, mypassword and the tablespace users with yours. The tables are created in the user's default
tablespace. A quota smaller than UNLIMITED works too, if it holds the replicated data. Why each privilege is needed:
see Privileges.
Leave the destination's Object Schema at the user ID (the default; see Create the destination), so the tables are created in the user's schema. For tables in a schema another user owns, see Tables in another schema.
Character set¶
Check that the database character set holds the source's characters (see Character set and length semantics).
Network¶
The Stelo VM must reach the Oracle listener's port, 1521 by default (1522 for Oracle Autonomous Database with
SSL/TLS). Connect to the service name of the database or PDB; lsnrctl status on the Oracle server lists the service
names.
Create the destination¶
Create the destination as described in Create a destination, with these choices:
-
Driver: the SQDR bundled Oracle driver is installed with SQDR: there's nothing to install. To use the Oracle ODBC driver instead, see The Oracle ODBC driver.
Docker
The SQDR container includes the SQDR bundled Oracle driver, not the Oracle ODBC driver: use the bundled driver there.
-
Name: choose the DBMS Type Oracle.
-
Connection: choose ODBC Driver and the driver, then the Template for Oracle, and fill in the fields (see Connection string).
-
Authentication: Remote Credentials with the user and password from Create the user. Click Verify.
- Tick Advanced to check the defaults: on the Default step, Object Schema is the schema where new subscriptions create their tables. It's the user ID by default; set it to the other schema if you followed Tables in another schema. See Defaults.
To keep a password out of the connection string, for example a key store password, use a secret. Verify tests the connection, not the privileges (see Test the privileges).
Connection string¶
SQDR bundled Oracle driver
HostName=myhostip;PortNumber=1521;ServiceName=myservice.mydomain.com, orSID=MYSIDinstead ofServiceName.- Multitenant (CDB): connect to the pluggable database (PDB) with its service name, not to the root container.
lsnrctl statuson the Oracle server lists the service names. - The Replicator Service sets the options it needs for this driver, including
ColumnSizeAsCharacter=1andColumnsAsChar=1, and for destinationsEnableBulkLoad(EBL=1) andEDP=1(describe parameters, which the Merge load needs) unless your string setsEDPorEnableDescribeParam; don't add them yourself. - Oracle Native Network Encryption (Advanced Security): set
EncryptionLevel,EncryptionTypes,DataIntegrityLevelandDataIntegrityTypesas your database requires. - SSL/TLS (required for Oracle Autonomous Database): convert the Oracle Wallet's keystore to PKCS12 (for example
with
keytool -importkeystore ... -deststoretype PKCS12), then addEM=1(Encryption Method: SSL),KeyStore=<path to keystore.p12>andKSP=<key store password>.VSC=0connects without validating the server certificate;VSC=1validates it and also needs the trust store (TrustStore). For example:HostName=adb.us-phoenix-1.oraclecloud.com;PortNumber=1522;ServiceName=myservice.adb.oraclecloud.com;KeyStore=C:\keystore\keystore.p12;KSP=$$ORA_KSP$$;VSC=0;EM=1. Keep the password in a secret.
Oracle ODBC driver (Oracle Instant Client)
DBQ=names the database: a TNS name fromtnsnames.ora(in the folderTNS_ADMINpoints to), or Easy Connect,DBQ=//myhost:1521/myservice. For a PDB, use the PDB's service name.- For SSL/TLS, configure the Oracle Wallet in
sqlnet.oraas Oracle documents (WALLET_LOCATION).
The Oracle ODBC driver¶
To use the Oracle ODBC driver instead of the bundled one, install Oracle Instant Client with its ODBC package on the Stelo VM (Windows). For its connection string, see Connection string.
Group settings for Oracle¶
When you create an incremental group to this destination, choose the DML Replication method (see Apply):
- Batch (the default), Merge and Sequence are all available. Merge is the fastest for high volumes
(see Choosing the apply method). Its merge tables,
SQDRWT_<id>, are global temporary tables in the user's own schema, which needsCREATE TABLE(see Create the user). It needs a key on every member: members without one are applied with inserts only (see Tables without a usable key). - For large tables, Allow disable/enable indexes makes baselines faster (see Disabling indexes during a baseline).
Check the destination¶
After the first baseline of the incremental group (for snapshots, after the first run):
- Group status. On the Groups page, the group shows Actively monitoring and applying change data (see
Group status). If a member failed, its
replication events show the Oracle error:
ORA-01031: insufficient privilegesnames a missing privilege,ORA-01950a missing quota. -
Rows at the destination. Compare a table's row count with the source:
SELECT COUNT(*) FROM sqdruser.mytable; -
Changes. Change a few rows at the source; they're applied with the group's next poll (the Poll Interval; see Scheduling). Query the rows again to see them.
What the Replicator Service runs on the database¶
The privileges in Prepare the database follow from these statements:
| When | Statements |
|---|---|
| A subscription is saved or a baseline starts (depending on its Destination DDL Options) | DROP TABLE and CREATE TABLE for the destination table. |
| Before a baseline or snapshot copies the data | TRUNCATE TABLE, or DELETE FROM ... WHERE ROWNUM <= n in batches with Delete existing data before replication (see Baseline Replication Options). |
| During the copy | INSERT, with ODBC parameter arrays. |
| Around the copy | CREATE INDEX and DROP INDEX for the index on the replication key (named after the table with the suffix IR) and for the source indexes you replicate; ALTER TABLE ... ADD CONSTRAINT ... PRIMARY KEY and ALTER TABLE ... DROP PRIMARY KEY DROP INDEX for Allow UPSERT members and replicated primary keys; ALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEY ... DISABLE for replicated foreign keys. See The key at the destination. |
| With Allow disable/enable indexes on the group | ALTER INDEX ... UNUSABLE before the copy and ALTER INDEX ... REBUILD after it, for the table's non-unique indexes, including yours (see Disabling indexes during a baseline). The Replicator Service finds the indexes left unusable in ALL_INDEXES. |
| Applying changes with Batch or Sequence | INSERT, UPDATE ... WHERE <key> and DELETE ... WHERE <key>, one row at a time. |
| Applying changes with Merge | CREATE GLOBAL TEMPORARY TABLE SQDRWT_<id> (...) ON COMMIT PRESERVE ROWS (and DROP TABLE of it) the first time a member is merged after the group starts; DELETE FROM SQDRWT_<id> and multi-row INSERT into it for each batch; then DELETE FROM <table> WHERE EXISTS (...) for the rows whose last change is a delete, and MERGE INTO <table> ... WHEN MATCHED THEN UPDATE ... WHEN NOT MATCHED THEN INSERT for the others. The merge table name has no schema, so Oracle creates it in the user's own schema (the connection's default schema), whatever schema the destination tables are in. See How Merge works. |
| With Merge In Place | A permanent merge table next to the destination table (or in the schema of the Decoration), created, emptied with TRUNCATE TABLE and dropped like a destination table. |
| ALTER processing | ALTER TABLE ... ADD (...), MODIFY, DROP (...) and RENAME COLUMN. ADD Copy also creates a work table SQDRCP_<id> next to the destination table, loads it and updates the destination table from it. |
Data types¶
The Replicator Service maps the source columns to the types the Oracle driver reports; see Data type mapping and its Per-database notes. For Oracle:
- Dates. Oracle has no date-only type: a source
DATEmaps to OracleDATE, which also holds a time (see Dates and times). - Empty strings. Oracle stores an empty string as NULL. During a baseline, an empty string goes into a nullable column as NULL; Default CHAR and VARCHAR as Nullable creates character columns as nullable for that reason (see Options that change the mapping).
- Character lengths are in characters by default (see Character set and length semantics).
- Numbers.
NUMBERis created asDECIMALwith the SQDR bundled driver. - LOBs. Large character and binary columns map to
CLOBandBLOB(andNCLOB). A subscription can have only oneLONGorLONG RAWdestination column. See LOB and long columns. - Names. With Fold case of identifiers per destination default (on by default), table and column names are
created in the case the driver reports for the database, upper case for Oracle.
ROWIDis reserved: rename the row identifier column of Oracle sources (see RRN and ROWID columns).
Limitations¶
- Merge tables stay in the schema. The
SQDRWT_<id>global temporary tables (and Merge In Place tables) stay in the user's schema after the group stops. Drop those of members you delete by hand (see The merge table). Don't create tables with these names. - Merge needs a key. The
MERGEmatches rows on the key columns; members without one are applied row by row with inserts only. - Replicated foreign keys are created disabled (
DISABLE), so they don't check the rows. - Identity columns. The Replicator Service doesn't create identity columns or sequences, and inserts the source's
values. A table you create yourself with a
GENERATED ALWAYS AS IDENTITYcolumn on a replicated column rejects those values. - Truncate.
TRUNCATE TABLEfails on a table referenced by an enabled foreign key; use Delete existing data before replication for such tables.
Troubleshooting¶
Problems and messages, with their causes and fixes, are in Troubleshooting › Oracle.
Related¶
- More about preparing an Oracle destination
- Prepare an Oracle database (as a source)
- Oracle documentation: System privileges, Choosing a character set