find out SELECT from view or table

In environments where you cannot differentiate whether an object is a view or a table from its name, you can quickly find out whether you are SELECTing from a view or table very quickly with set autotrace traceonly explain.

 

SET autotrace traceonly explain
18:15:01 NFP2DEV3:APPS@newfielddev3>select * from ap_invoices
18:15:08   2  /
Elapsed: 00:00:00.53
 
Execution Plan
----------------------------------------------------------
Plan hash value: 3474762098
 
--------------------------------------------------------------------------------
-----
| Id  | Operation         | Name            | Rows  | Bytes | Cost (%CPU)| Time
    |
--------------------------------------------------------------------------------
-----
|   0 | SELECT STATEMENT  |                 | 13145 |  3581K| 20243   (4)| 00:02
:35 |
|*  1 |  TABLE ACCESS FULL| AP_INVOICES_ALL | 13145 |  3581K| 20243   (4)| 00:02
:35 |
--------------------------------------------------------------------------------
-----
 
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - filter(NVL("ORG_ID",NVL(TO_NUMBER(DECODE(SUBSTRB(USERENV('CLIENT_INFO'
              ),1,1),' ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))=NVL
(TO_NUMBER(
              DECODE(SUBSTRB(USERENV('CLIENT_INFO'),1,1),'
              ',NULL,SUBSTRB(USERENV('CLIENT_INFO'),1,10))),(-99)))

 

In the above example, after turning on autotrace and explain only (that is I don’t want to actually run the query), the output from SELECT from ap_invoice gives me the explain plan.

In the plan I see that my query SELECTs from ap_invoices_all.

I also see that there are additional filters, probably from row level security.

Finding the last query in Oracle Applications

oracle applications last query 

1.) Goto Help
2.) Click on Diagnostics
3.) Then Examine
4.) In the first field (block) enter SYSTEM
5.) For Field enter LAST_QUERY
6.) Then click on Values
7.) You will see last query