Skip to content

Logical Dataguard Apply State (vldstate.sql)

This script provides a quick status check of logical standby databases by:

  • Showing whether real-time apply is enabled
  • Displaying the current state of the SQL Apply process
  • Setting appropriate date formats for timestamp clarity
  • Supporting remote database queries via database links
rem vldstate.sql
rem
ttitle 'Logical Dataguard Apply State'
set linesize 80
col state format A20 heading 'STATE'
col realtime_apply format a10 heading 'REALTIME'
set feedback off
alter session set nls_date_format='DD-MON-YYYY HH24:MI:SS';
alter session set nls_timestamp_format='DD-MON-YYYY HH24:MI:SS';
alter session set nls_timestamp_tz_format='DD-MON-YYYY HH24:MI:SS.FF5';
define inst='@ngp1gl1'
SELECT realtime_apply, state
FROM v$logstdby_state&inst
/
SQL> @vldstate.sql

To query a local standby (remove or modify the database link):

-- Edit the script and change:
define inst='@ngp1gl1'
-- To:
define inst=''
  • SELECT on V$LOGSTDBY_STATE
  • Database link privileges if querying remote standby
Logical Dataguard Apply State
REALTIME STATE
---------- --------------------
ENABLED APPLYING_LOG
  • REALTIME: Real-time apply status
    • ENABLED: Changes applied as soon as received
    • DISABLED: Changes applied only from archived logs
  • STATE: Current SQL Apply state
    • APPLYING_LOG: Actively applying changes
    • IDLE: Waiting for new redo data
    • ERROR: Apply process encountered errors
    • LOADING DICTIONARY: Building LogMiner dictionary
    • INITIALIZING: Starting up SQL Apply
  • APPLYING_LOG: Healthy, actively processing
  • IDLE: Normal when caught up with primary
  • ERROR: Check DBA_LOGSTDBY_EVENTS for details
  • LOADING DICTIONARY: May indicate rebuild needed
  • Extended IDLE: Could indicate transport issues
  1. Health Checks

    • Quick standby status verification
    • Pre-maintenance validation
    • Post-change confirmation
  2. Monitoring Integration

    • Automated status checks
    • Alert on ERROR state
    • Track state changes
  3. Troubleshooting

    • First step in lag investigation
    • Verify apply is running
    • Check real-time apply configuration
ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;
ALTER DATABASE STOP LOGICAL STANDBY APPLY;
ALTER DATABASE START LOGICAL STANDBY APPLY;
SELECT name, value
FROM v$parameter
WHERE name LIKE '%logstdby%';

If state shows ERROR:

  1. Check alert log for detailed errors
  2. Query DBA_LOGSTDBY_EVENTS
  3. Verify primary database is accessible
  4. Check for skip rules blocking apply

If REALTIME is DISABLED but wanted:

  1. Stop and restart apply with IMMEDIATE
  2. Verify standby redo logs configured
  3. Check MAX_SGA and MAX_SERVERS settings