This post covers the Oracle GoldenGate Tokens.
Oracle GoldenGate tokens are attributes to store environment variable values, which are available on the header of trail record header. Using Oracle GoldenGate built-in function @token within the parameter files retrieves the token value.
Types of Tokens:
There are two types of tokens. They are:
- Pre-defined token
- User Tokens
1. Pre-defined Tokens:
Below lists pre-defined Oracle GoldenGate tokens.
|TK_HOST||Stores the hostname|
|TK_GROUP||Stores the operating system group name|
|TK_OSUSER||Stores the operating system user name|
|TK_DOMAIN||Stores the hostname domain|
|TK_COMMIT_TS||Stores the current commit transaction sequence number|
|TK_POS||Stores the current read position|
|TK_RBA||Stores the relative byte address (RBA)|
|TK_TABLE||Stores the table name|
|TK_OPTYPE||Stores the operation types (INSERT, UPDATE, DELETE or DDL)|
The replicat rep2202 parameter file illustrates a basic implementation of the token by associating each row with Oracle GoldenGate environment pre-defined tokens values that can be used by other applications such as auditing.
Name Null? Type
———————————- ——– ———
DEPT_NO NOT NULL NUMBER
Loc NOT NULL VARCHAR2(128)
USERID ***, PASSWORD ***
MAP ggtraining1.dept, TARGET ggtraining2.dept, &
Dept_no = dept_no,
Loc = Loc
host = @TOKEN (‘TK_HOST’),
gg_group = @TOKEN (‘TK_GROUP’),
osuser = @TOKEN (‘TK_OSUSER’),
domain = @TOKEN (‘TK_DOMAIN’),
ba_ind = @TOKEN (‘TK_BA_IND’),
commit_ts = @TOKEN (‘TK_COMMIT_TS’),
pos = @TOKEN (‘TK_POS’),
rba = @TOKEN (‘TK_RBA’),
tablename = @TOKEN (‘TK_TABLE’),
optype = @TOKEN (‘TK_OPTYPE’));
2. User Defined Tokens:
These are defined on the source system and moved to the target system for event handling, providing an extendibility for attributes that are not pre-defined by Oracle GoldenGate. Tokens are a way to capture and store data in the header of the trail file. Once a token has been defined, captured and stored in the header, it can be retrieved, on the apply side, and used in many ways to customize what information is delivered by Oracle GoldenGate.
Follow the below steps to define the token:
- You define the token and the associated data.
- The token header in the trail file header permits up to a total of 2,000 bytes (token name, associated data, and length of data)
- Use the TOKEN option of the TABLE parameter in Extracts
Token data may be used in the COLMAP clause of a Replicat MAP statement, within an SQLEXEC, a UserExit, or a Macro. To retrieve the token data from the Oracle GoldenGate Trail, use the Column Conversion Function @TOKEN as input to any of the previously mentioned parameters.
In order to define a token in an extract, the definition should follow this basic syntax:
Userid ***,password ***
TRANLOGOPTIONS INTEGRATEDPARAMS(MAX_SGA_SIZE 1024)
TABLE ggtraining1.dept, TOKENS( SRC_CSN_TS = @GETENV(‘GGHEADER’,’COMMITTIMESTAMP’));
In the example above, the token will be populated with the timestamp of the last commit on the table it is defined against. After restarting the extract, the token (SRC_CSN_TS) will be included in the header of the trail file.
Once the trail file is shipped to the target side and read by the replicat, the token is mapped to a column in the target table.
|MAP ggtraining1.dept, target ggtraining2.dept,
Tokens are simple to create, use, and are a powerful feature for mapping data between environments.
- Oracle GoldenGate 12c Overview & Components: Manager | Extract | Collector | Replicat | Data Pump
- Oracle GoldenGate: Supplemental Logging & Its Importance
- [Video] Oracle GoldenGate 12c Microservices Architecture MA: Components, Documentation & Installation
- Oracle GoldenGate 12c: Step by step Activity Guides
This post is from our Oracle GoldenGate 12c Administration Training, in which we cover the Architecture, Installation, Configuring & Preparing the Environment, DML Replication – Online Change Synchronization, Initial Load, Zero Downtime Migration & Upgrading using GoldenGate, Oracle GoldenGate Security, Performance of Oracle GoldenGate and Troubleshooting and much more.
Did you Register for the FREE GoldenGate Masterclass?
NO? So, your next task is to get yourself registered for our FREE Masterclass on Learn Oracle GoldenGate 12c for Replication & Migration to start your GoldenGate journey. Click on the image below to register for FREE.