The DBMS_METADATA package provides a way for you to retrieve metadata from the database dictionary.
There are different subprograms to help us to get scripts of creation objects which helps to get an idea about the attribute of the objects.
Several subprograms of DBMS_METADATA Package are,
1)GET_DDL /GET_XML (used to fetch named objects, especially schema objects (tables, views)).
2)GET_DEPENDENT_DDL/GET_DEPENDENT_XML (used to fetch dependent objects (audits, object grants)).
3)GET_GRANTED_DDL/GET_GRANTED_XML (used to fetch granted objects (system grants, role grants)).
Example:
--------------
1)Fetch the DDL for all Complete Tables in the Current Schema, Filter Out Nested Tables and Overflow Segments:
SET LONG 2000000
SET PAGESIZE 0
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM
(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name)
FROM USER_ALL_TABLES u
WHERE u.nested='NO'
AND (u.iot_type is null or u.iot_type='IOT');
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT');
2)Fetch the DDL For All System Grants Granted To Arju.
-----------------------------------------------------
SELECT DBMS_METADATA.GET_GRANTED_DDL('SYSTEM_GRANT','ARJU') from dual;
3)Fetch the DDL For All Object Grants On ARJU.TEST
-------------------------------------------------
SELECT DBMS_METADATA.GET_DEPENDENT_DDL('OBJECT_GRANT',
'TEST','ARJU') FROM DUAL;
---------------------
GRANT SELECT ON "ARJU"."TEST" TO "TEST1"
4)Fetch the DDL for Table ARJU.TEST:
------------------------------------
SELECT DBMS_METADATA.GET_DDL('TABLE','TEST','ARJU') from dual;
Here first argument is object_type second one is table name and third one is owner name. If you own the table then while querying you can omit third argument as by default it takes current user.
In order to see the lists of object type which you can query from DBMS_METADAT.GET_DDL have a look at http://arjudba.blogspot.com/2008/06/table-view-tablespace-creation-script.html
Related Documents
How to get different object_type creation Script
Extract DDL from dump file
Sunday, April 13, 2008
Subscribe to:
Post Comments (Atom)
Tag Cloud
10.2g
10g
11g
11gR2
Abasa
About Oracle
Administration
Adsense
Alerts
Archival
ASM
ASP.Net
Audit
Audit Vault
Backup
Bangladesh
Block Corruption
Blogger
Browser
Bug
Business
Clone
Clusterware
Comments
Concepts
Connection
Controlfiles
Crime
CSS
Data Block
Data Dictionary
Data Guard
Data Mining
Data Pump
Data Type
Database Administration
Database Vault
DBConsole
Developer
Economics
EM
Excel
Exercise
Explain plan
Export
External Table
Facebook
Firefox
Firmware
Flashback
Forum
Functions
Games
Globalization Support
Grid Control
Hardware
History
HTML
IE
Import
Indexes
initializaion parameter
initialization parameter
Installation
Internals
Internet
Interview
isql*plus
Java
JavaScript
Job
Joins
Joke
Limitation
Linux
Listener
Logminer
Magento
Mail
Materialized View
Medical
Memory
Mobile
Money
Multimedia
MySQL
Net Services
Network
OCP
Operators
Oracle
Oracle Concepts
Oracle Recovery
OS
Others
OUI
Package
Packages
Parameters
Partitioning
Patchset
Performance
Perl
Pfile
Photos
PHP
PL/SQL
Profile
Pseudocolumns
Puzzle
Quiz
Quota
RAC
RAC Installation
Recovery
Recovery Problems
Redo Log
Reports
RMAN
Scripts
Security
SEO
Server Administration
SGA
Shell Script
Smarty
Social Marketing
Solaris
Spfile
SQL
SQL Tuning
SQL*Loader
Sql*Plus
Startup Problem
Streams
SwingBench
System Analysis
Tablespaces
Technology
Temp
TNS Error
Tools
Troubleshooting
Tuning
Undo
UNIX
Upgradation
Utilities
Version
Views
Vmware
Windows
Wordpress
XML
No comments:
Post a Comment