Friday, 15 September 2017

Get the SQL_ID of the statement

1. Run the sql statement.

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
PRDWCS7   READ WRITE


2. Run below 
select * from table(dbms_xplan.display_cursor(null));


SQL> select * from table(dbms_xplan.display_cursor(null));

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  9czut73sxc2y4, child number 0
-------------------------------------
select name,open_mode from v$database

Plan hash value: 3039639316

----------------------------------------------------------------------
| Id  | Operation            | Name     | Rows  | Bytes | Cost (%CPU)|
----------------------------------------------------------------------
|   0 | SELECT STATEMENT     |          |       |       |     1 (100)|
|   1 |  MERGE JOIN CARTESIAN|          |     1 |    14 |     0   (0)|

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------
|*  2 |   FIXED TABLE FULL   | X$KCCDI  |     1 |    14 |     0   (0)|
|   3 |   BUFFER SORT        |          |     1 |       |     0   (0)|
|   4 |    FIXED TABLE FULL  | X$KCCDI2 |     1 |       |     0   (0)|
----------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("DI"."INST_ID"=USERENV('INSTANCE'))


21 rows selected.


3. you will get the output.

SQL_ID  9czut73sxc2y4


No comments:

Post a Comment