Configure a self-managed Oracle database for CDC

This page describes how to configure change data capture (CDC) to stream data from a self-managed Oracle database to a supported destination, such as BigQuery or Cloud Storage.

You can configure your self-managed Oracle database to work with the following CDC methods:

These methods specify how Datastream accesses your log files. For more information about the binary log reader and the LogMiner API, see Work with Oracle database redo log files.

For detailed instructions about how to configure your source Oracle database for each of these methods, see the sections that follow.

Configure your self managed Oracle database for binary log reader

To configure your self-managed Oracle database for use with the binary log reader CDC method, perform the following steps:

  1. Create a database user account to be used by Datastream to connect to your database:

    CREATEUSERUSER_NAMEIDENTIFIEDBYUSER_PASSWORD;

    Replace the following:

    • USER_NAME: the name of the database user account that you want to use to connect to your database.
    • USER_PASSWORD: the password for the database user account.
  2. Select one of the following methods to access your log files:

    • Automatic Storage Management (ASM): if you select this option, you need to create a dedicated ASM connection, and provide its details when you create your connection profile. The user account used for the ASM connection must have the SYSASM privilege.

      To create a new ASM user with the SYSASM privilege, run the following commands:

      CREATEUSERASM_USER_NAMEIDENTIFIEDBYASM_PASSWORD;
      GRANTSYSASMTOASM_USER_NAME;

      Replace the following:

      • ASM_USER_NAME: the name of the ASM user.
      • ASM_PASSWORD: the password for the ASM user.
    • Database directories: if you select this option, you need to create database directory objects that point to the redo log files and the archived log files, and grant READ access to the directories to your database user:

    CREATEDIRECTORYDIRECTORY_NAME_1as'ONLINE_REDO_LOGS_PATH';
    CREATEDIRECTORYDIRECTORY_NAME_2as'ARCHIVED_REDO_LOGS_PATH';
    GRANTREADONDIRECTORYDIRECTORY_NAME_1toUSER_NAME;
    GRANTREADONDIRECTORYDIRECTORY_NAME_2toUSER_NAME;

    Replace the following:

    • DIRECTORY_NAME_1: the name of the directory for the online redo log files.
    • DIRECTORY_NAME_2: the name of the directory for the archived redo log files.
    • ONLINE_REDO_LOGS_PATH: the path to the directory where online redo log files are to be stored.
    • ARCHIVED_REDO_LOGS_PATH: the path to the directory where archived log files are to be stored.
    • USER_NAME: the name of the database user account created earlier.

    If you select the binary log reader method and use database directories, you need to provide the redo log and archived log directory names when you create your stream.

  3. Verify that your database is running in ARCHIVELOG mode.

    To do so, sign in to your Oracle database and run the following command at the SQL prompt:

    SELECT LOG_MODE FROM V$DATABASE;

    1. If the result is ARCHIVELOG, then move on to the next step.
    2. If the result is NOARCHIVELOG, then you'll need to enable ARCHIVELOG mode for your database.
    3. Run the following commands when logged in as SYSDBA:

      SHUTDOWNIMMEDIATE;
      STARTUPMOUNT;
      ALTERDATABASEARCHIVELOG;
      ALTERDATABASEOPEN;
    4. Archived log files consume disk space, so you'll want to configure the DB_RECOVERY_FILE_DEST_SIZE parameter for your database. Use this parameter to specify (in bytes) the hard limit on the total space to be used by target database recovery files. By setting this parameter, you can manage the tradeoff between protecting the database from running out of disk space and the stream failing because of log position loss.

  4. Define a data retention policy for your database by running these Oracle Recovery Manager (RMAN) commands:

    TARGET/
    CONFIGURERETENTIONPOLICYTORECOVERYWINDOWOF4DAYS;

    We recommend that you retain backups and archive logs for a minimum of 4 days, and 7 days is recommended.

  5. Return to the SQL prompt of the database tool that you're using to configure the Oracle log file rotation policy. We recommend setting a maximum log file size of no more than 512MB.

  6. Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:

    ALTERDATABASEADDSUPPLEMENTALLOGDATA;

    Next, choose whether to turn on logging for specific tables or the entire database.

    To log changes only for specific tables, run the following command for each table that you want to replicate:

    ALTERTABLESCHEMA.TABLEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;

    Replace the following:

    • SCHEMA: the name of the schema that contains the table.
    • TABLE: the name of the table for which you want to log changes.

    To replicate most or all tables in your database, consider turning logging on for the entire database. Run the following command to enable supplemental log data for the entire database:

    ALTERDATABASEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;
  7. Grant the appropriate privileges directly to the user account that's used to connect to your database. Note that these grants don't work when assigned to a role, for example. To do so, run the following commands:

    GRANTSELECTONGV_$LOGTOUSER_NAME;
    GRANTSELECTONGV_$LOGFILETOUSER_NAME;
    GRANTSELECTONGV_$ARCHIVED_LOGTOUSER_NAME;
    GRANTSELECTONGV_$INSTANCETOUSER_NAME;
    GRANTSELECTONGV_$STANDBY_LOGTOUSER_NAME;
    GRANTSELECTONV_$INSTANCETOUSER_NAME;
    GRANTSELECTONV_$PDBSTOUSER_NAME;
    GRANTSELECTONV_$TRANSPORTABLE_PLATFORMTOUSER_NAME;
    GRANTSELECTONV_$DATABASETOUSER_NAME;
    GRANTSELECTONV_$PARAMETERTOUSER_NAME;
    GRANTSELECTONCOL$TOUSER_NAME;
    GRANTSELECTONDBA_OBJECTSTOUSER_NAME;
    GRANTSELECTONDBA_TABLESPACESTOUSER_NAME;
    GRANTSELECTONDBA_ENCRYPTED_COLUMNSTOUSER_NAME;
    GRANTSELECTONDBA_EXTENTSTOUSER_NAME;
    GRANTCONNECTTOUSER_NAME;
    GRANTCREATESESSIONTOUSER_NAME;
    GRANTSELECTANYTABLETOUSER_NAME;

    Replace USER_NAME with the name of the database user account created earlier.

Configure your self managed Oracle database for LogMiner

  1. Create a database user account to be used by Datastream to connect to your database:

    CREATEUSERUSER_NAMEIDENTIFIEDBYUSER_PASSWORD;

    Replace the following:

    • USER_NAME: the name of the database user account that you want to use to connect to your database.
    • USER_PASSWORD: the password for the database user account.
  2. Verify that your database is running in ARCHIVELOG mode.

    To do so, sign in to your Oracle database and run the following command at the SQL prompt:

    SELECT LOG_MODE FROM V$DATABASE;

    1. If the result is ARCHIVELOG, then move on to the next step.
    2. If the result is NOARCHIVELOG, then you need to enable ARCHIVELOG mode for your database.
    3. Run the following commands when logged in as SYSDBA:

      SHUTDOWNIMMEDIATE;
      STARTUPMOUNT;
      ALTERDATABASEARCHIVELOG;
      ALTERDATABASEOPEN;
    4. Archived log files consume disk space, so you'll want to configure the DB_RECOVERY_FILE_DEST_SIZE parameter for your database. Use this parameter to specify (in bytes) the hard limit on the total space to be used by target database recovery files. By setting this parameter, you can manage the tradeoff between protecting the database from running out of disk space and the stream failing because of log position loss.

  3. Define a data retention policy for your database by running these Oracle Recovery Manager (RMAN) commands:

    TARGET/
    CONFIGURERETENTIONPOLICYTORECOVERYWINDOWOF4DAYS;

    We recommend that you retain backups and archive logs for a minimum of 4 days, and 7 days is recommended.

  4. Return to the SQL prompt of the database tool that you're using to configure the Oracle log file rotation policy. We recommend setting a maximum log file size of no more than 512MB.

  5. Enable supplemental log data. To do so, first enable minimal database-level supplemental logging by running the following command:

    ALTERDATABASEADDSUPPLEMENTALLOGDATA;

    Next, choose whether to turn on logging for specific tables or the entire database.

    To log changes only for specific tables, run the following command for each table that you want to replicate:

    ALTERTABLESCHEMA.TABLEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;

    Replace the following:

    • SCHEMA: the name of the schema that contains the table.
    • TABLE: the name of the table for which you want to log changes.

    To replicate most or all tables in your database, consider turning logging on for the entire database. Run the following command to enable supplemental log data for the entire database:

    ALTERDATABASEADDSUPPLEMENTALLOGDATA(ALL)COLUMNS;
  6. Grant the appropriate privileges directly to the user account that's used to connect to your database. Note that these grants don't work when assigned to a role, for example. To do so, run the following commands:

    GRANTEXECUTE_CATALOG_ROLETOUSER_NAME;
    GRANTCONNECTTOUSER_NAME;
    GRANTCREATESESSIONTOUSER_NAME;
    GRANTSELECTONSYS.V_$DATABASETOUSER_NAME;
    GRANTSELECTONSYS.V_$LOGTOUSER_NAME;-- for primary databases
    GRANTSELECTONSYS.V_$STANDBY_LOGTOUSER_NAME;-- for standby databases
    GRANTSELECTONSYS.V_$LOGFILETOUSER_NAME;
    GRANTSELECTONSYS.V_$ARCHIVED_LOGTOUSER_NAME;
    GRANTSELECTONSYS.V_$LOGMNR_CONTENTSTOUSER_NAME;
    GRANTSELECTONSYS.V_$PARAMETERTOUSER_NAME;
    GRANTEXECUTEONDBMS_LOGMNRTOUSER_NAME;
    GRANTEXECUTEONDBMS_LOGMNR_DTOUSER_NAME;
    GRANTSELECTANYTRANSACTIONTOUSER_NAME;
    GRANTSELECTANYTABLETOUSER_NAME;

    If your database uses Transparent Data Encryption (TDE), grant the following permissions:

    GRANTSELECTONDBA_TABLESPACESTOUSER_NAME;
    GRANTSELECTONDBA_ENCRYPTED_COLUMNSTOUSER_NAME;

    If your organization doesn't permit granting the GRANT SELECT ANY TABLE permission, use the solution described in the Oracle change data capture (CDC) section of the Datastream FAQ page.

    If your source database is Oracle 12c or newer, then grant the following additional privilege:

    GRANTLOGMININGTOUSER_NAME;
  7. Grant the user account SELECT access to the DBA_EXTENTS view in your database. This privilege lets you use the ROWID based backfill for your Oracle source:

    GRANTSELECTONDBA_EXTENTSTOUSER_NAME;

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026年08月26日 UTC.