Display the text of a cached query in the shared pool, then the execution plan. : V_sql « System Tables Views « Oracle PL / SQL

Oracle PL / SQL
1. Aggregate Functions
2. Analytical Functions
3. Char Functions
4. Constraints
5. Conversion Functions
6. Cursor
7. Data Type
8. Date Timezone
9. Hierarchical Query
10. Index
11. Insert Delete Update
12. Large Objects
13. Numeric Math Functions
14. Object Oriented Database
15. PL SQL
16. Regular Expressions
17. Report Column Page
18. Result Set
19. Select Query
20. Sequence
21. SQL Plus
22. Stored Procedure Function
23. Subquery
24. System Packages
25. System Tables Views
26. Table
27. Table Joins
28. Trigger
29. User Previliege
30. View
31. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Oracle PL / SQL » System Tables Views » V_sql 
Display the text of a cached query in the shared pool, then the execution plan.
    
SQL>
SQL> SELECT sql_text
  2  FROM v$sql
  3  WHERE sql_text LIKE '%&1%'
  4    AND sql_text NOT LIKE '%v$sql%'
  5    and rownum < 20
  6  /
Enter value for 1:
old   3WHERE sql_text LIKE '%&1%'
new   3WHERE sql_text LIKE '%%'

SQL_TEXT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
select id, name, block_size, advice_status,                  size_for_estimate, size_factor, buffers_for_estimate,        estd_physical_read_factor, estd_physical_reads,
   estd_physical_read_time,                                     estd_pct_of_db_time_for_reads,                       estd_cluster_reads,
      estd_cluster_read_time                                       from   gv$db_cache_advice where inst_id = userenv('instance')

delete from user_history$ where user# = :1
DECLARE  STATUS VARCHAR2(20);  DSTART DATE;  DSTOP DATE;  PVALUE NUMBER;  PNAME VARCHAR2(30)BEGIN  PNAME := 'mbrc';  DBMS_STATS.GET_SYSTEM_STATS(status, dstart, dstop, pname, pva
lue, stattab => ' mystats', statid => 'DAY', statown => 'java2s');  DBMS_OUTPUT.PUT_LINE('average multiblock readcount: '||pvalue)END;

SELECT NULL FROM DR$INDEX WHERE IDX_STATUS = :B2 AND IDX_OWNER# = -USERENV('SESSIONID') AND IDX_NAME = :B1
update sys.job$ set this_date=:where job=:2
update sys.job$ set this_date=:where job=:2
select ts# from ts$ where name=:1
SELECT  topology   FROM  SDO_TOPO_METADATA_TABLE a, TABLE(a.Topo_Geometry_Layersb   WHERE b.owner = 'JAVA2S'  AND b.table_name = 'ORD'
SELECT  DBMS_METADATA.GET_DDL('TABLE', 'emp', 'STUDENT1') FROM DUAL
delete from idl_sb4$ where obj#=:and part=:and version<>:3
update histgrm$ set col#=col#-:where (obj#=:or obj#=:3and col#>:4
delete from  viewtrcol$ where obj#=:1

SQL_TEXT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
begin "SYS"."DBMS_REPCAT_UTL"."DROP_USER_REPSCHEMA"(:myuser)end;
begin ::= ctxsys.drvxmd.NextIndexObject(:2,:3,:4);end;
begin ::= ctxsys.drvxmd.NextIndexObject(:2,:3,:4);end;
DELETE FROM SYS.AUX_STATS$ WHERE SNAME = 'SYSSTATS_INFO'
SELECT IXO_CLA_ID, IXO_OBJ_ID, IXO_ACNT FROM DR$INDEX_OBJECT WHERE IXO_IDX_ID = :B1 ORDER BY IXO_CLA_ID
delete from defrole$ where user#=:and role#=:and not exists (select null from sysauth$ where grantee#=and privilege#=:2)
begin "SYS"."DBMS_REGISTRY_SYS"."DROP_USER"(:myuser)end;

19 rows selected.

SQL> col id format 99
SQL> col operation format a20
SQL> col options format a20
SQL> col object_name format a30
SQL> col cost format 9999
SQL>
SQL> SELECT id, operation, options, object_name, cost
  2  FROM v$sql_plan VP, v$sql VS
  3  WHERE VP.address = VS.address
  4    AND VP.hash_value = VS.hash_value
  5    AND sql_text LIKE '%&1%'
  6    AND sql_text NOT LIKE '%v$sql%'
  7    and rownum < 20
  8  ORDER BY id
  9  /
Enter value for 1:
old   5:   AND sql_text LIKE '%&1%'
new   5:   AND sql_text LIKE '%%'

 ID OPERATION            OPTIONS              OBJECT_NAME                     COST
--- -------------------- -------------------- ------------------------------ -----
  DELETE STATEMENT                                                             2
  SELECT STATEMENT                                                             3
  DELETE STATEMENT                                                             1
  DELETE                                    FGACOL$
  DELETE                                    OBJAUTH$
  TABLE ACCESS         BY INDEX ROWID       OBJAUTH$                           3
  INDEX                RANGE SCAN           I_FGACOL
  INDEX                RANGE SCAN           I_OBJAUTH1                         2
  INDEX                RANGE SCAN           I_OBJAUTH1                         2
  NESTED LOOPS                                                                53
  TABLE ACCESS         BY INDEX ROWID       USER$                              1
  TABLE ACCESS         BY INDEX ROWID       OBJ$                               3
  INDEX                RANGE SCAN           I_OBJ2                             2
 10 TABLE ACCESS         BY INDEX ROWID       NTAB$                             12
 11 INDEX                RANGE SCAN           I_NTAB3
 12 TABLE ACCESS         CLUSTER              COL$                               1
 13 NESTED LOOPS                                                                18

 ID OPERATION            OPTIONS              OBJECT_NAME                     COST
--- -------------------- -------------------- ------------------------------ -----
 14 INDEX                RANGE SCAN           I_OBJAUTH1                         2
 15 FIXED TABLE          FULL                 X$KZSRO                           16

19 rows selected.

SQL>

   
    
    
    
  
Related examples in the same category
1. Query v$sql for sql text
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.