Today I found a sketch of an ERD from last year when I looked at the new features of PL/Scope in version 12.2. It looked a bit complicated and also wrong. So, I decided to refactor it using SQL Developer Data Modeler and share the result.
You find the model in the plscope-utils Github project here.
The implementation provides the following views:
DBA/ALL/USER_IDENTIFIERS
for the entities “Identifier Declaration” and “DB Object Usage”DBA/ALL/USER_STATEMENTS
for the entities “Identifier Declaration”, “SQL Stmt Usage” and “SQL Statement”
For me the most interesting entity was “Identifier Declaration”, because it helped me to understand the signature
attribute/column. PL/Scope creates a signature
for every database object and all its components when a database object is compiled with PL/Scope or when a referenced object cannot be compiled with PL/Scope. I call those objects “Secondary Objects”. Such objects are tables, views, materialized views, operators or sequences. Hence you find PL/Scope metadata for every table which is referenced in the PL/SQL code after compiling it with PL/Scope. Here’s an example:
SELECT usage, type, name, line, col, usage_id, usage_context_id FROM user_identifiers WHERE object_type = 'TABLE' AND object_name = 'EMP' ORDER BY line, col; USAGE TYPE NAME LINE COL USAGE_ID USAGE_CONTEXT_ID ----------- ------ -------- ---- ---- -------- ---------------- DECLARATION TABLE EMP 1 15 1 0 DECLARATION COLUMN EMPNO 1 22 2 1 DECLARATION COLUMN ENAME 1 51 3 1 DECLARATION COLUMN JOB 1 77 4 1 DECLARATION COLUMN MGR 1 100 5 1 DECLARATION COLUMN HIREDATE 1 118 6 1 DECLARATION COLUMN SAL 1 134 7 1 DECLARATION COLUMN COMM 1 152 8 1 DECLARATION COLUMN DEPTNO 1 171 9 1
The PL/Scope metadata for table emp
will be removed automatically when there are not used by “Primary Objects” (objects which can be compiled with PL/Scope) anymore. Quite nice.