Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 

 

 

Oracle dbms_ddl tips


Oracle Database Tips by Donald Burleson


Oracle's tools (pre 10g wrap) and post 10g dbms_ddl are NOT encryption.  Rather, they are simple obfuscation, guarding against casual viewing of the source code. .

 

Oracle never states in the documentation  obfuscation is a secure solution, they say its obfuscation.  It would be interesting to see when Oracle will offer encryption tool for PL/SQL.

Using Oracle dbms_ddl

There is an analyze_object procedure that is part of the Oracle dbms_ddl package that has similar, but not quite as powerful, functionality. This procedure must be created by a user with select access on the dba_tables view and the required privileges to analyze the specified schema/owner.

I suggest an account similar to the SYSTEM account. Remember that stored objects cannot be created based on privileges from a role, so even the SYSTEM account must be given a direct grant on the dba_tables view.

Some dbms_ddl notes:

  • dbms_ddl.analyze schema:  Oracle provides many ways to analyze SQL optimizer statistics, and Oracle recommends using the dbms_stats package.  It is not always a good idea to use Oracle's dbms_utility.analyze_schema or the dbms_ddl.analyze_object packages to perform this task.

  • Using the dbms_ddl.wrap procedure to encrypt PL/SQL

It's important for vendors who write applications using Oracle PL/SQL to protect their intellectual property and encrypt their PL/SQL source code.

Oracle has two method for encrypting PL/SQL, the wrap.exe and the dbms_ddl.wrap utility in release 10.2 and onwards.

The dbms_ddl.wrap procedure accepts as input a parameter containing a PL/SQL create or replace statement and dbms_ddl.wrap returns the obfuscated PL/SQL, which can be written to a file or stored in a table. Dr. Tim Hall has this outstanding example of using the dynamic PL/SQL encryption function:

SET SERVEROUTPUT ON SIZE UNLIMITED
DECLARE
l_source VARCHAR2(32767);
l_wrap VARCHAR2(32767);
BEGIN
l_source := 'CREATE OR REPLACE FUNCTION get_date_string RETURN VARCHAR2 AS' ||
'BEGIN ' ||
'RETURN TO_CHAR(SYSDATE, ''DD-MON-YYYY''); ' ||
'END get_date_string;';

l_wrap := SYS.DBMS_DDL.WRAP(ddl => l_source);
DBMS_OUTPUT.put_line(l_wrap);
END;
/
CREATE OR REPLACE FUNCTION get_date_string wrapped

a000000
b2
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
6f
aa
mV4eMSJ8EqqgErJT91l6UZ0pdDUwgyr6LZ5GfHSmUPiJfkEObQpeDb6D7glajI+ONulxdqC1
0HvOPP4eJpQs5zxsKXpj6XL1
fvieXyWCr3BTzXTqcGYhfXrtqDVPztR/o+9UZ8l5OijDSsRW
ZPv6rISzFyqeEsCBweFUFyxd

In addition to the wrap functions, the dbms_ddl package also contains three overloaded procedures called create_wrapped. These procedure have the same parameter lists as the three wrap function overloads, and are used to wrap and compile the specified source.

The following example shows how the dbms_sql.varchar2a version is used:

SET SERVEROUTPUT ON SIZE UNLIMITED
DECLARE
l_source DBMS_SQL.VARCHAR2A;
l_wrap DBMS_SQL.VARCHAR2A;
BEGIN
l_source(1) := 'CREATE OR REPLACE FUNCTION get_date_string RETURN VARCHAR2 AS ';
l_source(2) := 'BEGIN ';
l_source(3) := 'RETURN TO_CHAR(SYSDATE, ''DD-MON-YYYY''); ';
l_source(4) := 'END get_date_string;';

SYS.DBMS_DDL.CREATE_WRAPPED(ddl => l_source,
lb => 1,
ub => l_source.count);
END;
/

PL/SQL procedure successfully completed.

SET PAGESIZE 100

SELECT text
FROM user_source
WHERE name = 'GET_DATE_STRING'
AND type = 'FUNCTION';

TEXT
------------------------------------------------------------------------
FUNCTION get_date_string wrapped
a000000
b2
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
6f aa
mV4eMSJ8EqqgErJT91l6UZ0pdDUwgyr6LZ5GfHSmUPiJfkEObQpeDb6D7glajI+ONulxdqC1
0HvOPP4eJpQs5zxsKXpj6XL1fvieXyWCr3BTzXTqcGYhfXrtqDVPztR/o+9UZ8l5OijDSsRW
ZPv6rISzFyqeEsCBweFUFyxd

The create_wrapped procedures are the equivalent of passing the wrapped source returned from the wrap function into an execute immediate or dbms_sql.parse call, but they are optimized to give better performance.

 

[http://dba-oracle.com/include_utility_book.htm]

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.