Table DDL Change Notification

This chapter explains how to use Table DDL Change Notification for receiving notifications about DDL changes in database tables.

Topics:

Overview of Table DDL Change Notification

Table DDL Change Notification provides Oracle Call Interface (OCI) clients an efficient mechanism to subscribe for DDL notifications on tables of interest. Table DDL Change Notification ensures that applications are notified when DDL statements make changes to a table. Changes are captured as DDL events and these events are processed asynchronously without blocking the user DML activity.

Applications seeking table metadata can use Table DDL Change Notification instead of continuously polling for DDL changes, and benefit from reduced network round trips. Table DDL Change Notification is also useful for OCI clients of the database that cache table metadata in the middle tier to avoid round trips to the database.

An OCI client can register to receive table DDL change notification for any of the following:

Table DDL Change Notification is included in Oracle AI Database 26ai, and later releases.

Table DDL Change Notification Terminology

OCI Client

An OCI client (client, client application) is a client program that calls the APIs in Oracle Call Interface (OCI).

EMON

Notification systems use the Event monitor (EMON) server pool to publish notifications to OCI clients.

Notification

A notification is a message describing the table DDL event that is sent to an OCI client. A notification does not contain the entire DDL statement but provides the table name and type of DDL operation.

Subscription

A subscription defines a channel that the clients can use to receive a particular notification.

Event

An event is a message published on a subscription, describing the DDL action on a table.

Registration

A registration represents a client that wants notification for a particular subscription topic.

Benefits of Table DDL Change Notification

Table DDL Change Notification works without affecting the application activity in the database.

The following are some of the benefits of using Table DDL Change Notification:

Features of Table DDL Change Notification

The following are the features of Table DDL Change Notification:

Using Table DDL Change Notification

Here is how the notification process works with Table DDL Change Notification:

DDL Event Payload

The event payload describes the DDL event that is notified to the client application. The attributes of the event include:

Registering Client Callback for DDL Notification

See Also: OCISubscriptionRegister() for more information about the user callback API.

Use Case: GoldenGate Replicat

Here is a use case that has Oracle GoldenGate Replicat as the client:

Oracle GoldenGate Replicat applies source DML and DDL changes at the target database during logical replication. During an application upgrade, in many instances, the target table structure is modified prior to making the corresponding changes to the source database. In such cases, DDL replication cannot be used to synchronize and reconcile the metadata between the source and the target database.

For example; suppose a source table called FA 1.AR_SALES_TAX is being replicated to the target database. Replicat loads the metadata of FA1.AR_SALES_TAX to reconstruct the SQL statement INSERT into FA1.AR_SALES_TAX values(..). The relevant metadata includes information, such as column names, column types, and whether the table is compressed. Since the table metadata rarely changes, Replicat caches the data instead of querying the target database repeatedly. When the table metadata is first cached, Replicat registers for table DDL events of FA1.AR_SALES_TAX on the target database.

Take a scenario where the FA1.AR_SALES_TAX table is modified on the target database directly (and not on the source). For example, additional columns are added to the target table without being added to the source database. Replicat is notified with the table name and the operation (for instance, ALTER). When Replicat receives a new transaction to apply, it can refresh its stale metadata based on the DDL events received and can replicate inserts into the newly added columns successfully.

Registering for Table DDL Change Notification

A client can register for DDL change notifications at the table level or the schema level (for schema-wide table DDL events).

To register for notifications, you must fulfill the following conditions:

Note: If a user loses the required privileges, the user’s table or schema-level registrations are implicitly unregistered.

Table-level Registration

To register for notifications at the table level, use the OCIDdlEventRegister() function.

See Also: OCIDdlEventRegister() in Oracle Call Interface Developer’s Guide for more information about the OCIDdlEventRegister() function and examples.

Here are some important points to note while registering for table-level notifications:

Schema-level Registration

To register for table DDL notifications at the schema level, use the OCIDdlEventRegister() function.

See Also: OCIDdlEventRegister() in Oracle Call Interface Developer’s Guide for more information about the OCIDdlEventRegister() function and examples.

Here are some important points to note while registering for schema-level notifications:

Unregistering for Table DDL Change Notifications

A client can unregister previously registered tables or schema using the OCIDdlEventUnregister() function. The client can select the tables and schemas to remove from registration.

To unregister DDL notifications at the table or schema level, use the OCIDdlEventUnregister() function.

See Also: OCIDdlEventUnregister() in Oracle Call Interface Developer’s Guide for more information about the OCIDdlEventUnregister() function and examples.

In the following cases, a table is automatically unregistered:

When a client application exits without unregistering, its unprocessed notifications are dropped when notification delivery fails. If the OCI client restarts, it needs to re-register to resume notifications.

Supported DDL Events and Commands

In general, space management operations on the table, partition or index are not supported.

Supported Events

The following DDL events are included for DDL notifications:

The following DDL events have conditional support for DDL notifications:

The following DDL events are excluded from DDL notifications:

Supported commands

At the table level, the following commands are supported:

At the PMOP level, the following commands are supported:

-

CREATE TABLE PARTITION [SUBPARTITION]

-

ALTER TABLE operation [PARTITION | SUBPARTITION]

Operation = [ ADD | DROP | MODIFY | EXCHANGE | MERGE | RENAME | SPLIT | TRUNCATE ]

At the constraint level, the following commands are supported:

ALTER TABLE operation CONSTRAINT

Operation = [ADD | MODIFY | RENAME | DROP]

At the Flashback level, the following commands are supported: FLASHBACK TABLE

At the index level, the following commands are supported:

Unsupported Commands

At the table level, the following commands are not supported:

At the PMOP level, MOVE operations are not supported.

At the index level, space management operations like REBUILD, COALESCE and SPLIT PARTITION are not supported.

Monitoring Table DDL Change Notification

The registration identifier (ID) uniquely identifies a subscription. A client can register on mutliple tables or schemas in the database using the same subscription (meaning, registration ID). The following views can be queried by the registration ID to monitor table DDL events received for a subscription.