With PL/Scope Oracle gives us a powerful but not necessary instantly likeable tool to analyse the metadata of PL/SQL code.
How does it work and how can it help you in your daily business?
PL/Scope? • Part of PL/SQL compiler since 11gR1 • Gathers information about all objects in PL/SQL and writes them into metadata tables • … and even about SQL statements (within PL/SQL)!
PL/Scope? • Part of PL/SQL compiler since 11gR1 • Gathers information about all objects in PL/SQL and writes them into metadata tables • … and even about SQL statements (within PL/SQL)!
PL/Scope good for? • Code Analysis Much more detail and semantics than simple text search Much more detail than DEPENDENCIES views • Check for Violation of Coding Guidelines Security Vulnerabilites • Gather Information Getting an overview of unknown code Refactoring
Start 1. Change settings 2. Compile all your code (or just the part you are interested in) ALTER SESSION SET plscope_settings= 'IDENTIFIERS:ALL, STATEMENTS:ALL' Please refer to the docs for more exotic settings
Start 1. Change settings 2. Compile all your code (or just the part you are interested in) ALTER SESSION SET plscope_settings= 'IDENTIFIERS:ALL, STATEMENTS:ALL'
Side" • Time • Only compile time is affected • Test with 61.000 lines showed an increase by a factor of 1.1 to 1.2 I didn't do any thorough testing as it didn't hurt
yourself: SELECT SPACE_USAGE_KBYTES FROM V$SYSAUX_OCCUPANTS WHERE OCCUPANT_NAME='PL/SCOPE'; The "Down Side" • Space • The metadata does need some space • My test with 61.000 lines needed ~ 26MB • My observation: less than a KB per line of code I didn't do any thorough testing as it didn't hurt
• Very detailed analysis: https://www.salvis.com/blog/2017/10/14/limitations-of- plscope-and-how-to-deal-with-them/ • Will hopefuly go away soon The "Down Side"
PL/Scope Utils: Extension for SQL Developer https://www.salvis.com/blog/download/ • Find bad performing queries or code with PL/Scope: https://nicetheory.io/2018/11/30/find-bad-performing-queries-or-code-with-pl-scope/
Development Guide: 14 Using PL/Scope http://docs.oracle.com/database/122/ADFNS/plscope.htm • Steven Feuerstein: Powerful Impact Analysis (Oracle Magazine) http://www.oracle.com/technetwork/issue-archive/2017/17-jan/o17plsql-3429342.html • Steven Feuerstein: Impact Analysis with PL/Scope (SildeShare) https://www.slideshare.net/StevenFeuerstein/impact-analysis-with-plscope • LiveSQL examples by Steven Feuerstein https://livesql.oracle.com/apex/f?p=590:49:::NO::P49_SEARCH:pl%2Fscope Reading List