Sometimes I am faced with a situation where I need to know the source for a view or a procedure or a function. Fortunately Oracle stores the source in the database.
First I check to see what kind of object whose source I need is.
SQL> select object_name,object_type,status from user_objects where object_name = 'FOO';
If the object is a table I can simply recreate the table by doing a desc on that object.
SQL> desc FOO;
If the object is a function or stored procedure you can find its source in the user_source table.
SQL> select text from user_source where name = 'FOO' order by line;
If the object is a view you can find its source in the user_views table.
SQL> select text from user_views where view_name = 'FOO';
If the output seems to be truncated it is because text is of type LONG which is a big binary field. To allow more output do this.
SQL> set long 4000
Thanks to this article and this forum for helping me figure this out.