Info Trandata from SQLPLUS Automation
Imagine a scenario where you need to verify supplemental logging on hundreds of tables after running the ADD TRANDATA or ADD SCHEMATRANDATA from the GoldenGate console or using Adminclient. Manually running ‘Info Trandata’ for each table through GoldenGate can be a tedious and time-consuming process. A practical solution? Crafting a simple script that performs this check quick & fast from your shell, saving you both time and effort.
ARCHITECTURE
Ways to check supplemental Logging
- Info Trandata from CLI of Admin Client or GGSCI
Eg : Info Trandata <schema>.<TableName> - Trandata Information from GoldenGate UI console.
- SQLPLUS method using the sql query.
select * from table(logmnr$always_suplog_columns( SCHEMA, TABLE ));
Why need for the script ?
Supplemental logging in Oracle databases adds extra logging information to the redo log files, which is essential for Oracle GoldenGate. Manually checking the supplemental logging status for each table can be tedious, especially in large databases. This is where the script comes into play, simplifying and automating this process.
Script Overview
This shell script operates by connecting to an Oracle database, fetching a list of table names from the specified schema (in this case, ‘SOE’), and then checking whether supplemental logging is enabled or disabled for each table. It categorizes the tables accordingly and provides a count for each category.
Key Features:
- Dynamic SID Input: The script accepts the Oracle SID (or PDB name) as a command-line argument, allowing flexibility and ease of use across different databases.
- Customizable Query: The SQL query within the script is tailor-made to fetch tables from the ‘FUSION’ schema but can be easily modified to suit other schemas.
- Supplemental Logging Check: It employs Oracle’s LOGMNR$ALWAYS_SUPLOG_COLUMNS to determine the supplemental logging status of each table.
- User-Friendly Output: The script neatly displays the tables with supplemental logging enabled and disabled, along with the respective counts.
#!/bin/bash
# Check if a SID is passed as an argument
if [ $# -eq 0 ]; then
echo "No Oracle PDB Name or ORACLE SID provided. Usage: $0 PDBNAME/ORACLE_SID"
exit 1
fi
# Use the first argument as the Oracle SID
DB_SID=$1
export ORACLE_PDB_SID=$DB_SID
# SQL query to get all table names from the SOE schema
SQL_QUERY="SELECT table_name FROM all_tables WHERE owner = 'SOE'"
# Function to check supplemental logging for a table
check_supplemental_logging() {
local table_name=$1
local check_query="SELECT 1 FROM TABLE(LOGMNR\$ALWAYS_SUPLOG_COLUMNS('FUSION', '${table_name}')) WHERE ROWNUM = 1"
local result=$(sqlplus -s / as sysdba <
Usage
To run the script, simply pass the Oracle SID/PDB_NAME as an argument:./supplemental_logging_check.sh ORACLE_SID / PDBNAME
Fetching table names...
Checking supplemental logging status...
-------------------------------------------------------------------
SUPPLEMENTAL LOGGING ENABLED TABLES (Count: 11):
-------------------------------------------------------------------
ORDERS
INVENTORIES
PRODUCT_DESCRIPTIONS
PRODUCT_INFORMATION
WAREHOUSES
ORDERENTRY_METADATA
LOGON
CARD_DETAILS
ORDER_ITEMS
ADDRESSES
CUSTOMERS
-------------------------------------------------------------------
SUPPLEMENTAL LOGGING DISABLED TABLES (Count: 0):
-------------------------------------------------------------------
For more information about documentation please check here.
Hope you found this article useful.
Disclaimer: The views expressed on this document are my own and do not necessarily reflect the views of Oracle.