Oracle
The Oracle target writes data to tables in a Oracle database. For information about supported versions, see Supported systems and versions.
You can use the Oracle target to write new data or change data capture (CDC) data to Oracle. The target writes data from record fields to table columns based on matching names. The target can compensate for data drift by creating new columns and tables in Oracle when new fields and table references appear in records.
The Oracle target uses a JDBC connection string or Oracle host and service name to connect to the Oracle database. When you configure the target, you specify the connection string or host and service name, and credentials to use to connect to the database. You can also use a connection to configure the target.
You configure the Oracle database and tables to use, and specify error handling.
You can optionally enable data drift. You can have the target create new tables, as needed. You can also specify whether to create all new columns as String instead of inferring the type.
Before you can use the Oracle target, you must complete a prerequisite task.
Prerequisite
Before using the Oracle target, install the Oracle JDBC driver for the database. The target cannot access the database until you install this driver.
- Download the Oracle JDBC driver from the Oracle website.Note: Writing XML data to Oracle requires installing the Oracle Data Integrator Driver for XML. For more information, see the Oracle documentation.
- Install the driver as an external library into the JDBC branded Oracle stage
library,
streamsets-datacollector-jdbc-branded-oracle-lib, which includes the source.
Enabling data drift handling
The Oracle target can automatically compensate for changes in column or table requirements, also known as data drift.
- Create new columns
-
The target can create new columns in Oracle tables when new fields appear in records. For example, if a record suddenly includes a new
Address2field, the target creates a newAddress2column in the target table.By default, the target creates new columns based on the data in the new fields, such as creating a Double column for decimal data. You can, however, configure the target to create all new columns as String.
- Create new tables
- The target can create new
tables as needed. For example, say the target writes data to
tables based on the region name in the
Regionfield. When a newSW-3region shows up in a record, the target creates a newSW-3table in Oracle and writes the record to the new table.
Generated data types
When creating new tables or creating new columns in existing tables, the Oracle target uses field names to generate the new column names.
| Record Field Data Type | Oracle Column Data Type |
|---|---|
| Byte Array | Binary Float |
| Char | Char |
| String | Varchar2 |
| Decimal | Number |
| Long | Long |
| Float | Float |
| Integer | Number |
| Short | Number |
| Date | Date |
| Datetime | Timestamp |
| Zoned Datetime | Timestamp With Time Zone |
| Double | Float |
The target does not support nested Data Collector data types: List, List-Map, and Map. By default, the target treats fields with invalid data types as an error record. You can configure the target to ignore fields with invalid data types, replacing them with an empty value.
Creating tables
If you configure the Oracle target to handle data drift, you can also configure the target to create tables. Once configured, the target creates tables when the specified or needed tables do not exist in Oracle.
- Table
- The target creates a table if the table specified in the Table Name property does not exist.
- Table columns
- In the created tables, the target determines the columns from the first batch of data processed. The target infers the data types from the data in the batch.
CRUD operation processing
The Oracle target can insert, update, upsert, or delete data when you configure the target to process CDC data.
sdc.operation.type record header attribute. The target
performs operations based on the following numeric values:- 1 for INSERT
- 2 for DELETE
- 3 for UPDATE
- 4 for UPSERT
If
your flow has a CRUD-enabled source that processes changed data, the
target simply reads the operation type from the sdc.operation.type
header attribute that the source generates. If your flow has a non-CDC
source, you can use the Expression Evaluator processor or a scripting processor to
define the record header attribute. For more information about Data Collector changed data processing and a list of
CDC-enabled sources, see Processing changed data.
Configuring an Oracle target
About this task
Configure an Oracle target to write data to Oracle tables.