Class SqlUtils


  • public class SqlUtils
    extends Object
    This utility class contains SQL statements to configure, manage and query Oracle LogMiner todo handle INVALID file member (report somehow and continue to work with valid file), handle adding multiplexed files, todo SELECT name, value FROM v$sysstat WHERE name = 'redo wastage'; todo SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE WHERE STATUS='INVALID'; (drop and recreate? or do it manually?) todo table level supplemental logging todo When you use the SKIP_CORRUPTION option to DBMS_LOGMNR.START_LOGMNR, any corruptions in the redo log files are skipped during select operations from the V$LOGMNR_CONTENTS view. todo if file is compressed? // For every corrupt redo record encountered, // a row is returned that contains the value CORRUPTED_BLOCKS in the OPERATION column, 1343 in the STATUS column, and the number of blocks skipped in the INFO column.
    • Constructor Detail

      • SqlUtils

        public SqlUtils()
    • Method Detail

      • setRac

        static void setRac​(boolean isRac)
      • redoLogStatusQuery

        static String redoLogStatusQuery()
      • switchHistoryQuery

        static String switchHistoryQuery()
      • currentRedoNameQuery

        static String currentRedoNameQuery()
      • currentRedoLogSequenceQuery

        static String currentRedoLogSequenceQuery()
      • databaseSupplementalLoggingAllCheckQuery

        static String databaseSupplementalLoggingAllCheckQuery()
      • databaseSupplementalLoggingMinCheckQuery

        static String databaseSupplementalLoggingMinCheckQuery()
      • tableSupplementalLoggingCheckQuery

        static String tableSupplementalLoggingCheckQuery​(TableId tableId)
      • currentScnQuery

        static String currentScnQuery()
      • oldestFirstChangeQuery

        static String oldestFirstChangeQuery​(Duration archiveLogRetention)
      • allMinableLogsQuery

        public static String allMinableLogsQuery​(Scn scn,
                                                 Duration archiveLogRetention,
                                                 boolean archiveLogOnlyMode)
        Obtain a query to fetch all available minable logs, both archive and online redo logs.
        Parameters:
        scn - oldest system change number to search by
        archiveLogRetention - duration archive logs will be mined
        archiveLogOnlyMode - true if to only mine archive logs, false to mine all available logs
        Returns:
        the query string to obtain minable log files
      • localArchiveLogDestinationsOnlyQuery

        private static String localArchiveLogDestinationsOnlyQuery()
        Returns a SQL predicate clause that should be applied to any ARCHIVED_LOG_VIEW queries so that the results are filtered to only include the local destinations and not those that may be generated by tools such as Oracle Data Guard.
      • startLogMinerStatement

        static String startLogMinerStatement​(Scn startScn,
                                             Scn endScn,
                                             OracleConnectorConfig.LogMiningStrategy strategy,
                                             boolean isContinuousMining)
        This returns statement to build LogMiner view for online redo log files
        Parameters:
        startScn - mine from
        endScn - mine till
        strategy - Log Mining strategy
        Returns:
        statement todo: handle corruption. STATUS (Double) — value of 0 indicates it is executable
      • logMinerContentsQuery

        static String logMinerContentsQuery​(OracleConnectorConfig connectorConfig,
                                            String logMinerUser)
        This is the query from the LogMiner view to get changes. The query uses the following columns from the view:
         SCN - The SCN at which a change was made
         SQL_REDO Reconstructed SQL statement that is equivalent to the original SQL statement that made the change
         OPERATION_CODE - Number of the operation code
         TIMESTAMP - Timestamp when the database change was made
         XID - Transaction Identifier
         CSF - Continuation SQL flag, identifies rows that should be processed together as a single row (0=no,1=yes)
         TABLE_NAME - Name of the modified table
         SEG_OWNER - Schema/Tablespace name
         OPERATION - Database operation type
         USERNAME - Name of the user who executed the transaction
         
        Parameters:
        connectorConfig - the connector configuration
        logMinerUser - log mining session user name
        Returns:
        the query
      • getExcludedUsers

        private static String getExcludedUsers​(String logMinerUser)
      • getExcludedDdlTables

        private static String getExcludedDdlTables()
      • listOfPatternsToSql

        private static String listOfPatternsToSql​(List<Pattern> patterns,
                                                  String columnName,
                                                  boolean applyNot)
      • resolveRegExpLikePattern

        private static String resolveRegExpLikePattern​(Pattern pattern)
      • addLogFileStatement

        static String addLogFileStatement​(String option,
                                          String fileName)
      • deleteLogFileStatement

        static String deleteLogFileStatement​(String fileName)
      • tableExistsQuery

        static String tableExistsQuery​(String tableName)
      • dropTableStatement

        static String dropTableStatement​(String tableName)
      • logMiningHistoryDdl

        static String logMiningHistoryDdl​(String tableName)
      • truncateTableStatement

        static String truncateTableStatement​(String tableName)
      • diffInDaysQuery

        public static String diffInDaysQuery​(Scn scn)
        This method return query which converts given SCN in days and deduct from the current day
      • connectionProblem

        public static boolean connectionProblem​(Throwable e)