---
title: "How to find tables being used in oracle cursor?"  
description: "How to find tables being used in oracle cursor?"  
author: "Steilla Mitchel"  
published: 2023-08-22  
updated: 2023-08-23  
canonical: https://www.mindstick.com/forum/159650/how-to-find-tables-being-used-in-oracle-cursor  
category: "database"  
tags: ["database table", "oracle"]  
reading_time: 2 minutes  

---

# How to find tables being used in oracle cursor?

How to find [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development) being used in [oracle](https://www.mindstick.com/articles/13016/alter-table-statement-or-command-in-oracle) [cursor](https://www.mindstick.com/articles/13003/create-a-simple-cursor-in-sql-server)?

## Replies

### Reply by Aryan Kumar

To find tables being used in an Oracle cursor, you can use the following steps:

1. Identify the cursor name.
2. Query the `v$cursor` data dictionary view to get the following information about the cursor:

   - The cursor name
   - The owner of the cursor
   - The SQL statement associated with the cursor
   - The number of rows fetched by the cursor
   - The status of the cursor (open, closed, etc.)

3. Extract the table names from the SQL statement associated with the cursor.

Here is an example of how to find tables being used in an Oracle cursor:

SQL

```plaintext
SELECT owner, table_name
FROM v$cursor
WHERE cursor_name = 'my_cursor';
```

This query will return a list of all tables that are being used by the cursor `my_cursor`.

You can also use the following PL/SQL code to find tables being used in an Oracle cursor:

SQL

```plaintext
DECLARE
  cursor_name VARCHAR2(30);
  v_owner VARCHAR2(30);
  v_table_name VARCHAR2(30);
BEGIN
  cursor_name := 'my_cursor';

  OPEN cursor_name;

  LOOP
    FETCH cursor_name INTO v_owner, v_table_name;
    EXIT WHEN cursor_name%NOTFOUND;

    dbms_output.put_line('Table: ' || v_table_name);
  END LOOP;

  CLOSE cursor_name;
END;
```

This code will first declare a cursor variable named `cursor_name` and initialize it to the name of the cursor you want to find tables for. It will then open the cursor and fetch the table names from the cursor one at a time. Finally, it will close the cursor.


---

Original Source: https://www.mindstick.com/forum/159650/how-to-find-tables-being-used-in-oracle-cursor

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
