Skip to main content

Oracle Database

This connector materializes Estuary collections into tables in an Oracle database.

Prerequisites​

To use this connector, you'll need:

  • An Oracle database to materialize into, and credentials for a database user.
    • The connector supports Oracle Database 23ai and later, including 26ai.
    • The database character set must be AL32UTF8.
    • The user must be able to create tables in the schema you configure, and must have a quota on that schema's tablespace.
    • For standard updates, the connector looks up existing documents using private temporary tables named ORA$PTT_FLOW_LOAD_<n>. These tables are only visible to the connector's own session. If your database's PRIVATE_TEMP_TABLE_PREFIX parameter has been changed from its default of ORA$PTT_, also grant the user SELECT on SYS.V_$PARAMETER so the connector can read the prefix.
  • At least one Estuary collection.

Setup​

  1. Connect to the pluggable database as an administrator and create a user for the connector. By default, the connector creates its tables in this user's own schema.

    CREATE USER flow_materialize IDENTIFIED BY "secret";
    GRANT CREATE SESSION, CREATE TABLE TO flow_materialize;
    ALTER USER flow_materialize QUOTA UNLIMITED ON USERS;

    If you want to materialize into a different schema, the user needs privileges on that schema instead. For example: CREATE ANY TABLE, ALTER ANY TABLE, DROP ANY TABLE, SELECT ANY TABLE, INSERT ANY TABLE, UPDATE ANY TABLE and DELETE ANY TABLE. The schema must already exist, because the connector doesn't create schemas.

  2. Make sure Estuary can reach your database. You can do either of the following:

Configuration​

Use the properties below to configure an Oracle materialization. Each binding writes one Estuary collection to one table in the database.

Properties​

Endpoint​

PropertyTitleDescriptionTypeRequired/Default
/addressAddressHost and port of the database. If you leave out the port, the connector uses 1521.stringRequired
/userUserDatabase user to connect as.stringRequired
/credentialsCredentialsCredentials for authentication.objectRequired
/credentials/auth_typeAuth TypeMethod to use for authentication.stringUserPassword
/credentials/passwordPasswordPassword for the user.stringRequired
/databaseDatabaseService name of the database (pluggable database) to materialize to.stringRequired
/schemaSchemaSchema where the connector creates its tables, including flow_checkpoints_v1. Defaults to the user's own schema.string
/sslmodeSSL Modeverify-full connects over TLS (TCPS) and checks the server's certificate and host name. require connects over TLS but skips those checks. disable connects over plain TCP.stringverify-full
/hardDeleteHard DeleteWhen a document is deleted in the source, delete its row from the table. When this is off, the row is kept and its _meta/op column is set to d.booleanfalse
/networkTunnelNetwork TunnelConnect to the database through an SSH server that acts as a bastion host for your network.object
/networkTunnel/sshForwardingSSH Forwardingobject
/networkTunnel/sshForwarding/sshEndpointSSH EndpointAddress of the SSH server, in the form ssh://user@hostname[:port].string
/networkTunnel/sshForwarding/privateKeySSH Private KeyPrivate key used to connect to the SSH server.string
/networkTunnel/sshForwarding/knownHostsSSH Known HostsHost keys of the SSH server in OpenSSH known_hosts format, one per line. This is what ssh-keyscan -p <port> <host> prints. The connector refuses to connect to an SSH server that doesn't present one of these keys.stringRequired when using a tunnel

Bindings​

PropertyTitleDescriptionTypeRequired/Default
/tableTableName of the table to materialize to. The connector creates the table if it doesn't exist yet.stringRequired
/schemaAlternative SchemaSchema for this table, if it should be different from the endpoint's schema.string
/delta_updatesDelta UpdateUse delta updates for this table instead of standard updates.booleanfalse

Sample​

materializations:
${PREFIX}/${mat_name}:
endpoint:
connector:
image: ghcr.io/estuary/materialize-oracle:v1
config:
address: oracle.example.com:1521
user: flow_materialize
credentials:
auth_type: UserPassword
password: secret
database: ORCLPDB1
sslmode: verify-full
bindings:
- resource:
table: ${TABLE_NAME}
source: ${PREFIX}/${COLLECTION_NAME}

TLS​

Oracle listens for TLS (TCPS) and plain TCP connections on separate ports, usually 2484 for TLS and 1521 for plain TCP. Make sure the SSL Mode you choose matches the port in the address.

  • verify-full checks that the server's certificate is signed by a public certificate authority and that it matches the host in the address. This check still applies when you connect through an SSH tunnel.
  • require uses TLS but doesn't check the certificate.
  • disable connects over plain TCP. In this mode the connection is only encrypted if the server asks for Oracle native network encryption, which the connector supports.

Changing the schema​

The connector tracks its progress in a table named flow_checkpoints_v1, which lives in the endpoint's schema. If you change the endpoint's schema, the connector creates a new, empty flow_checkpoints_v1 table there, and the materialization starts over from the beginning.

Table and column names​

Oracle converts unquoted names to upper case. The connector follows the same rule where it can, so that you can query your tables without quoting names:

  • A table or field name that is a valid unquoted Oracle identifier and isn't a reserved word is stored in upper case. For example, orderId becomes ORDERID.
  • Any other name keeps its exact spelling and case, and you need to quote it in queries. For example, _meta/op and order id must be written as "_meta/op" and "order id".

Oracle doesn't allow double quotes inside a name, so the connector replaces them with underscores.

Names can be at most 128 bytes long. Non-ASCII characters take more than one byte each, so a name that contains them has to be shorter than 128 characters.

Data types​

Collection typeOracle column type
integerNUMBER(38,0). If the schema allows values that don't fit in 64 bits, the column is a VARCHAR2, like a string.
number, or string with format: numberBINARY_DOUBLE
booleanBOOLEAN
stringVARCHAR2 of the largest size the database allows. Converted to CLOB if a value is too long (see Long strings).
string with format: integerNUMBER(38,0). If the field's maxLength is more than 38, the column is a VARCHAR2, like a string.
string with format: dateDATE
string with format: date-timeTIMESTAMP(9) WITH TIME ZONE, stored in UTC
string with contentEncoding: base64BLOB
object, array, or a field with multiple typesCLOB containing JSON
the root document (flow_document)CLOB containing JSON

Collection keys​

Oracle only allows certain types in a primary key, so key fields are mapped differently:

  • String keys, including dates and date-times, are VARCHAR2(1000 CHAR), whatever the field's maxLength.
  • Binary keys are RAW(2000).

The materialization fails if a key value is longer than its column.

Empty strings​

Oracle treats an empty string or an empty binary value as NULL. This has two consequences:

  • String and binary columns always allow NULL, even when the field is required in the collection.
  • A key can't be NULL, so the materialization fails if a string or binary key field has an empty value.

Numbers that become strings​

If a field's type changes from number to string, the connector converts the existing values in the column to text. Numbers are written the same way they appear in JSON, so 0.1 stays 0.1.

Date limits​

Oracle has no year 0, so a date in year 0 is stored as 0001-01-01.

Date-times are converted to UTC and must fall between the years 1 and 9999. A date-time outside that range is stored as the earliest or latest moment Oracle supports.

Long strings​

A string column that isn't part of the key starts out as the largest VARCHAR2 the database allows. That is 4000 bytes, or 32767 bytes if the database's MAX_STRING_SIZE parameter is set to EXTENDED. The connector uses VARCHAR2 rather than CLOB because you can filter, group and compare a VARCHAR2 column like any other text.

If a value turns out to be too long for the column, the connector:

  1. Rolls back the current transaction.
  2. Converts the column to a CLOB. This rewrites the column in every row of the table, so it can take a while on a large table.
  3. Stops with an error that names the column.

The materialization then restarts on its own and retries the transaction, which now succeeds. Once a column has become a CLOB, it stays a CLOB.

Transactions​

The connector writes all the rows of one Estuary transaction in a single Oracle transaction. Your database's undo tablespace needs enough room for the largest of these. Transactions are biggest during the first backfill of a large collection, and when the connector removes old rows after a backfill (see Backfills).

Backfills​

When you backfill a collection, the table may still contain rows that were written before the backfill and that the backfill didn't write again. Usually these are documents that no longer exist in the source. Once the backfill completes, the connector removes them from tables that use standard updates:

  • With hard deletes enabled, the rows are deleted.
  • Without hard deletes, the rows are kept and their _meta/op column is set to d. This only works if the binding includes the _meta/op field.

Tables that use delta updates aren't affected.

Delta updates​

This connector supports both standard (merge) updates and delta updates. Standard updates are the default.

Reserved words​

Oracle reserves words such as DATE, NUMBER and ORDER. If a table or field name is a reserved word, the connector quotes it, which means it keeps its exact case and you need to quote it in your queries too. See the Oracle documentation for the full list.