Using GV$ Cursor

Introduction

Ever wanted to be able to run a SQL command across multiple RAC nodes but cant find a GV$ view for it? For example, reading the alert logs? Well an undocumented function allows just such a thing. Its called gv$cursor.

Using GV$ Cursor

By placing your SQL statement inside the gv$cursor function you are telling Oracle to run what is in the cursor on each node in the cluster and return the results with an inst_id

SELECT inst_id, col1, col2, col3
FROM 
  TABLE (gv$
            (CURSOR 
              (
                <<<<Insert Your SQL Statement Here>>>>>
              )
            )
         )
ORDER BY 
  inst_id, 
  col1,
  col2
  col3
/

A working example can be found here


Published 1st May 2022

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License