snippetMinor
How to extract Procedure, Function, etc. Source Code from an Oracle Export
Viewed 0 times
oraclehowsourcefunctionprocedureexportextractcodefrometc
Problem
I have generated an
I then ran the following command to generate a file containing the 'Create Table...' statements:
This is great for the Create Table statements, but I also want the Create Procedure / Create Function / Create View source code. I can see them there in the .DMP file, but I haven't found a way to extract them.
Is it possible to extract this information from the EXPDAT.DMP file? Or will I need to use another method?
The purpose is to have the source exportable to files that can be source-controlled.
EXPDAT.DMP file of an Oracle database with the command:exp userid=usr/pass@db owner=own rows=n compress=nI then ran the following command to generate a file containing the 'Create Table...' statements:
imp userid=usr/pass@db full=y indexfile=output.sqlThis is great for the Create Table statements, but I also want the Create Procedure / Create Function / Create View source code. I can see them there in the .DMP file, but I haven't found a way to extract them.
Is it possible to extract this information from the EXPDAT.DMP file? Or will I need to use another method?
The purpose is to have the source exportable to files that can be source-controlled.
Solution
If you've got access to the original database, I'd go with DBMS_METADATA.GET_DDL.
You can script it with UTL_FILE so that it goes through each object (from USER_OBJECTS), uses the name and type to extract the object then write it to a file that has the appropriate naming convention.
It will be a lot cleaner than trying to split a single file.
You can script it with UTL_FILE so that it goes through each object (from USER_OBJECTS), uses the name and type to extract the object then write it to a file that has the appropriate naming convention.
It will be a lot cleaner than trying to split a single file.
Context
StackExchange Database Administrators Q#2811, answer score: 7
Revisions (0)
No revisions yet.