Mohamed Houri’s Oracle Notes

August 6, 2011

On the use of dbms_metadata.get_ddl

Filed under: Oracle — hourim @ 3:48 pm

A question recently came into an oracle French forum (http://www.developpez.net/forums/d1117051/bases-donnees/oracle/source-vue-format-text/)  asking about how to get a DDL of views containing a given text

I thought it is worth writing here the English translation of my French answer to that thread. I will start by creating a view in which I will use the term ‘Mohamed’


mhouri.world> create view view_test as
2  select *
3  from emp
4  where ename = 'Mohamed';
View created.

And now we would like to get views that contains the text ‘Mohamed’ in their DDL creation script.


mhouri.world> SELECT *
2    FROM
3    (SELECT
4           dbms_metadata.get_ddl('VIEW', view_name) txt
5     FROM  user_views
6    ) ww
7  WHERE
8     dbms_lob.instr (ww.txt, 'Mohamed') != 0
9  ;

CREATE OR REPLACE FORCE VIEW "MHOURI"."VIEW_TEST" ("EMPNO", "ENAME", "JOB", "MGR
", "HIREDATE", "SAL", "COMM", "DEPTNO") AS
select "EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO"
from emp
where ename = 'Mohamed'

Hope this will help.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Tony's Oracle Tips

Tony Hasler's light hearted approach to learning about Oracle

Richard Foote's Oracle Blog

Focusing Specifically On Oracle Indexes, Database Administration and Some Great Music

Hatem Mahmoud Oracle's blog

Just another Oracle blog : Database topics and techniques

Mohamed Houri’s Oracle Notes

Qui se conçoit bien s’énonce clairement

Oracle Diagnostician

Performance troubleshooting as exact science

Raheel's Blog

Things I have learnt as Oracle DBA

Coskan's Approach to Oracle

What I learned about Oracle

So Many Oracle Manuals, So Little Time

“Books to the ceiling, Books to the sky, My pile of books is a mile high. How I love them! How I need them! I'll have a long beard by the time I read them”—Lobel, Arnold. Whiskers and Rhymes. William Morrow & Co, 1988.

EU Careers info

Your career in the European Union

Carlos Sierra's Tools and Tips

Tools and Tips for Oracle Performance and SQL Tuning

Oracle Scratchpad

Just another Oracle weblog

OraStory

Dominic Brooks on Oracle Performance, Tuning, Data Quality & Sensible Design ... (Now with added Sets Appeal)

%d bloggers like this: