You are now on my old blog. Please update your bookmarks to my new blog
http://laurentschneider.com




22 November 2005

post from palindnilap

I just answered a question about the data dictionary on forums.oracle.com. It is all about the dictionary views.
How many tables should I know in the dictionary ?

SQL> select count(*) from dict;
1857

Well, that's too much. But I can remove the GV$ view, which contain the instance for RAC, and the DBA_ ALL_ and USER_ have (almost) the same structure.

SQL> select count(*)
from dict
where table_name not like 'GV$%'
and table_name not like 'ALL%'
and table_name not like 'DBA%' ;
712

Anyway, who knows the 712 views by heart? Hopefully, there is one called DICTIONARY, which helps !

Coming back to the post, palindnilap wants to see which columns of a view are mapped to which column of a table. A quick look at ALL_VIEWS could do the trick, but than you will need to "understand" the query to see which view.column maps to which table.column. What's more, ALL_VIEWS.TEXT is a long. Arghh!

if you have a view that contains all columns from a table, you could use ALL_DEPENDENCIES to see on which table it is based.

On my first answer, I pointed out that ALL_UPDATABLE_COLUMNS may reveal that a view column belongs to a table if the column is updatable.

My last try was to use the ACCESS_PREDICATES to get the column physically accessed.

SQL> select * from v02 where employee=123456;

no rows selected

SQL> select
max(substr(ACCESS_PREDICATES,1,instr(ACCESS_PREDICATES,'=')-1))
from v$sql_plan
where ACCESS_PREDICATES like '%=123456';
"EMPNO"

here we see EMPLOYEE is actually named "EMPNO" in the based table. It could be done with explain plan and PLAN_TABLE too.

0 Comments:

Post a Comment

<< Home