Getting DDL for all oracle objects

I am working to get the DDL for all the oracle objects within my schema.
Some how I got the DDL but I can't got the comments associated with the oracle tables.
Shall I know what I am missing in using dbms_package I am currently using ..?
Below is the sql I am using to get DDL
SELECT dbms_metadata.get_ddl(replace(OBJECT_TYPE, ' ', '_'), OBJECT_NAME,OWNER)
FROM DBA_OBJECTS
WHERE OBJECT_TYPE in ('SEQUENCE',
'PROCEDURE',
--'DATABASE LINK',
'PACKAGE',
'PACKAGE BODY',
'MATERIALIZED VIEW',
'TABLE',
'INDEX',
'VIEW',
'FUNCTION')
AND
OWNER = 'Schema_1';
Can I know what needs to be changed to above sql to get comments on oracle tables along with their DDL.
Any advise is highly appreciated.
Thanks
JP

>
I am still MISSING ';' after every sql and comments.
>
You only get what you ask for. If you want modifications you have to set the proper transform parameters.
See DBMS_METADATA in the PL/SQL Packages and Types doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_metada.htm
See SET_TRANSFORM_PARAM and SET_REMAP_PARAM Procedures and table 74-22 that list the parameters you can use
Here are some examples from Java code that I use depending on flags that have been set
-- set the transforms back to the defaults
        String defaultTransform   = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'DEFAULT'); END;";
-- do not include referential constraints
        String ref_constraints    = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS', false); END;";
-- do not include constraints
        String constraints        = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS', false); END;";
-- do not include the schema prefix
        String noschema           = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'EMIT_SCHEMA', false); END;";
-- make it look pretty
        String pretty             = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY', true); END;";
-- don't include the physical properties
        String physicalProperties = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PHYSICAL_PROPERTIES', false); END;";
-- don't include the segment attributes
        String segmentAttributes  = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES', false); END;";
-- include a sql terminator for each statement
        String sqlterminator      = "BEGIN DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR', true); END;";The last one is what you are looking for.

Similar Messages

  • Can you get DDL for more than a single object?

    I need to have the ability to select from the list of objects (say tables for this example) and generate the DDL for all or some of the tables. At this point I can only see how I can get the DDL for a single table.

    It's coming hopefully i'll have it done in the next EA drop.
    -kris

  • Getting TreePath for all nodes in a JTree

    Hi everybody
    I want to get TreePath for all the nodes in a JTree
    Can anybody help me?

    Hi,
    i tried to used your code.
    there is a problem, it is not taking the entire paths.
    so if you have some children,it takes the paths only for the fathers.
    so i correct it to the following way(it will take the entire paths):
    public void getPathForAllNodes(TreePath path)
                  Object node = path.getLastPathComponent();
                  pathArrayList.add(path);
                  TreeModel model = tree.getModel();
                  if(model.isLeaf(node))
                  return;
                  int num = model.getChildCount(node);
                  for(int i = 0; i < num; i++)
                       //pathArrayList.add(path);
                       getPathForAllNodes(path.pathByAddingChild(model.getChild(node, i)));
             }thanks for your code

  • How to get DDL Script in Oracle 11g

    How can i get DDL Script in Oracle 11g database.
    I am using windows as OS
    Can anyone help me to get solution.
    Thanks in Advance

    parapr wrote:
    How can i get DDL Script in Oracle 11g database.
    I am using windows as OS
    Can anyone help me to get solution.
    Thanks in AdvanceHUH?
    might DBMS_METADATA.GET_DDL() provide what you desire?

  • Interface for all cost object related transtions with third party system

    Hello Guru's
    I have one required for Functional Specications i.e,  i need to create interface for all cost object related transtions with third party system for this purpose i need to create FS. any body please guide how to do..

    Hi sreedhar royals
    You need to check controlling tables you need to interact. (CSKS, COAS,....) then ask your abaper and project manager to guide you.
    Regards

  • Ecc6, after i've changed all the passwords for all oracle users, then how

    ECC6, after i've changed all the passwords for all oracle users, now sap can't connect to oracle , then,  How can i config the sap to make sure it can boot normal?
    If our database is sqlserver, i've changed the database password for all database users, then, How can i config the sap?
    Thanks!

    My db is oracle ,                           the oracle host name is dbserver.
    The sap ap server only install the SAP. SAP host name is apserver.
    Just now i've altered all the password of the oracle database db user account, Include the account "sys".
    (I must alter the password.)
    Now the SAP service in the host "apserver" can't boot.
    Could you teach me  how can i config the "apserver" to make the SAP normal boot ?
    Thanks!
    Best regards!

  • Extract DDL for all objects separately !

    Hi All
    I have a huge DB having 3000 tables (having indexes,triggers,synonym), 1200 functions/procedures, 1000 views etc.
    I need to extract only metadata and put into a version control repository.
    I need to extract all objects (tables,procs,functions,views) in separate files, with the grants for each procs/func/table/view in the respective procs/func/table/view file only.
    Indexes should be in respective table file only. Each object (procs/func/table/view etc) should have DROP command in the beginning.
    I tried sql developer, but it gives separate files for grants,indexes,triggers,drops etc and also gives option to generate one script for all tables, one for all views, one for all indexes and so on, so doesn't satisfy my requirement.
    Please suggest me a good tool (preferably FREE one) to extract the metadata in said fashion.
    Thanks.

    AnkitV wrote:
    Hi All
    I have a huge DB having 3000 tables (having indexes,triggers,synonym), 1200 functions/procedures, 1000 views etc.
    I need to extract only metadata and put into a version control repository.
    I need to extract all objects (tables,procs,functions,views) in separate files, with the grants for each procs/func/table/view in the respective procs/func/table/view file only.
    Indexes should be in respective table file only. Each object (procs/func/table/view etc) should have DROP command in the beginning.The hard part is the requirement of separating the items into different files.
    sb2075's answers are your best option. Write a PL/SQL script on the server to use DBMS_METADATA.GET_DDL or whatevever equivalent extraction routine will work for you. Loop through the objects you need from the data dictionary and writing the data using UTL_FILE. The simplified logic should look something like
    foreach table
      get the ddl
      generate filename
      open file
      write ddl
      close file>
    I tried sql developer, but it gives separate files for grants,indexes,triggers,drops etc and also gives option to generate one script for all tables, one for all views, one for all indexes and so on, so doesn't satisfy my requirement.You don't want to manually use SQL*Developer to do 3000 extractions anyways. The script should do it all for you.

  • Getting control totals for all the objects

    Hi All,
    1. I want to get the control totals for all the tables along with table names in Oracle
    the below I google and found, but I am not aware of xml in Oracle, I tested this on small scott db it works fine
    select
    table_name,
    to_number(
    extractvalue(
    xmltype(
    dbms_xmlgen.getxml('select count(*) c from '||table_name)
    ),'/ROWSET/ROW/C')) count
    from user_tables order by 1is the above query correct?
    2. I want all the view name
    This I can get it from user_views ( but I want for entire database excluding system views and only user created views)
    select view_name from user_objects3. I want all the sporc name( including the ones in the package and stand alone)
    I am not sure how to get this.

    Be aware of the statement "Some columns in these views contain statistics that are generated by the DBMS_STATS package or ANALYZE statement."
    See this page specially "Columns marked with an asterisk (*) are populated only if you collect statistics on the table with the ANALYZE statement or the DBMS_STATS package."
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10820/statviews_2117.htm#REFRN20286
    If your statistic is not updated, it can give you totally wrong impression.

  • Getting tasks for all users in a role

    Hi,
    We need to get all users in a Role, and out of those, find out which one has the least tasks in their UWL using a WebService. Saw some example codes and here's my attempt at it. Doesn't quite work, I'm getting the Logged in users context or session doesn't exist Exception. Any help on this will be GREATLY appreciated.
    public class LeastTasksBean implements LeastTasksLocal {
         public String getUserLeastTasks( String sRole )
              try{
                   Map<String, String> users = new HashMap<String, String>();
                   Map<String, String> tasks = new HashMap<String, String>();
                   final int sessionIdleTimeout = 60;
                   String Users[] = UMFactory.getRoleFactory().getUsersOfRole( sRole, true );
                   if( Users != null ){
                        for( int i = 0; i < Users.length; i ++ ){
                             UWLContext  uwlContext      = new UWLContext();
                             IUWLService uwlService      = findService();
                             uwlContext.setAllowBackEndConnections( true );
                             IUser uwlContextUser        = UMFactory.getUserFactory().getUser( Users[0] );
                             uwlContext.setUser            ( uwlContextUser );
                             Locale loc                  = new Locale( "ES" );
                             uwlContext.setLocale          ( loc );
                             HttpServletRequest request  = getHttpRequest();
                             uwlContext.setOriginRequest   ( request );
                             IUWLSession session         = uwlService.beginSession( uwlContext, sessionIdleTimeout );
                             uwlContext.setSession         ( session );
                             IUWLItemManager itemManager = uwlService.getItemManager( uwlContext );
                             QueryResult result          = itemManager.getItems( uwlContext, null, null );
                             users.put( String.valueOf( i ), uwlContext.getUserName() );
                             tasks.put( String.valueOf( i ), String.valueOf( result.getItems().size() ) );
                             uwlService.endSession( uwlContext );
                        int userTasks = 0;
                        int leastTasks = Integer.valueOf( tasks.get( 0 ) );
                        int userKey = 0;
                        for( int i = 0; i < Users.length; i ++ ){
                             userTasks = Integer.valueOf( tasks.get( Integer.toString( i ) ) );
                             if( userTasks < leastTasks ){
                                  leastTasks = userTasks;
                                  userKey = i;
                        return users.get( Integer.toString( userKey ) );
                   else{
                        return "No users exist for this role";
              //Exception Handling
         private IUWLService findService() throws NamingException
              Properties properties = new Properties();
              properties.put( InitialContext.INITIAL_CONTEXT_FACTORY, "com.sapportals.portal.prt.registry.PortalRegistryFactory" ); 
              InitialContext ctx = new InitialContext( propiedades ); 
              IUWLService uwlService = ( IUWLService ) ctx.lookup( IUWLService.ALIAS_KEY );
              return uwlService;
         private HttpServletRequest getHttpRequest() throws Exception
              Properties properties = new Properties();
              properties.put( "domain", "true" );
              ApplicationWebServiceContext wsContext =
                   (ApplicationWebServiceContext) new InitialContext( propiedades ).lookup( "/wsContext/" + ApplicationWebServiceContext.APPLICATION_WSCONTEXT );
              HttpServletRequest request = wsContext.getHttpServletRequest();
              return request; 

    Hi David,
    I have a similar requirement on our project. I need to get a count of pending workitems for all user but I'm getting similar message when I try to access UWL context of any other user.
    Did you find any solution for this? Is it possible to get the workitems for all users using webservice or wendynpro?
    I would appreciate if you can provide some inputs on this.
    Thank you in advance.
    Regards,
    Seema Rane

  • VAT amount get fixed for all the miro

    when i am doing a miro, in the VAT G/L i am getting a fixed amount of VAT value i.e RS 29500.00. i have check in mking out 10 MIro . but the VAT  value remain fixed.what should i do
    regard
    nabil

    Hi,
    VAT value is flowing from purchase order & VAT value depending the tax code available in the purchase order. You can check VAT value as % in FTXP t.code or FV13 with combination of tax code & VAT condition type.
    As you are getting same vale of VAT now in MIRO(same vale of VAT should not come for all PO in MIRO), may be purchase orders are having same quantity. Now just cross check again & again by doing MIRO with other purchase orders without posting, just carry out simulate document, check accounting entries.
    Regards,
    Biju K

  • How to setup em for all oracle database templetas X86/X86_64 /10g/11g

    Hi: everyone know about Oracle database templates X86/X86_64 /10g/11g all not setup em.
    I have builder all Oracle database templates X86/X86_64 can not start em
    https://hostname:1158/em
    $emctl start dbconsole
    to display Oc4j configurate issue......
    I have do
    $emca -repos create
    $emca -config dbcontrol db
    $emctl start dbconsole
    but still not login em.
    Everyone can test it,why can not running.
    How to config about em.
    thank.

    Hi:
    $emctl status dnconsole
    Oracle Enterprise Manager 11g Database Control Release 11.1.0.6.0
    Copyright (c) 1996,2007 Oracle Corporation .All righs reserved.
    https://majin148:5500/em/console/aboutApplication
    Oracle Enterprise Manager 11g is running
    I am also to try:
    #chkconfig iptables off
    https://192.168.100.148:5500/em

  • Using dbms_metadata to get ddl for creating directories

    Hi,
    I am working on creating a test database, which is a copy of production for 11g upgrade testing. I want to get all the ddls from my production databse to create all the directories in the new test database. I have been trying to use dbms_metadata for this -
    Below is the code that I have been trying to use. However, when I query the my_metadata table, there is nothing in there. Can someone please help me with this?
    DROP TABLE my_metadata;
    CREATE TABLE my_metadata(md CLOB);
    CREATE OR REPLACE PROCEDURE progp1_directories_extract
    AS
    hndl NUMBER; --dbms_metadata handle
    th NUMBER; --transform handle
    DDL CLOB; --individual clobs extracted from the database
    BEGIN
    hndl := DBMS_METADATA.OPEN ('DATABASE_EXPORT'); --Open the metadata
    DBMS_METADATA.set_filter (hndl, 'INCLUDE_PATH_EXPR', '=''DIRECTORY'''); --Filter data as appropriate
    th := DBMS_METADATA.add_transform (hndl, 'DDL'); --Get the Transform Handle
    DBMS_METADATA.set_transform_param (th, 'SQLTERMINATOR', TRUE); --Include the semicolon
    LOOP
    DDL := DBMS_METADATA.fetch_clob (hndl); --Loop through the result set, inserting into our temp table
    EXIT WHEN DDL IS NULL;
    INSERT INTO my_metadata
    (md)
    VALUES (DDL);
    COMMIT;
    END LOOP;
    DBMS_METADATA.CLOSE (hndl);
    EXCEPTION
    WHEN OTHERS
    THEN
    NULL;
    END;
    show errors

    user12158503 wrote:
    Below is the code that I have been trying to use. However, when I query the my_metadata table, there is nothing in there. Can someone please help me with this?
    DROP TABLE my_metadata;
    CREATE TABLE my_metadata(md CLOB);
    CREATE OR REPLACE PROCEDURE progp1_directories_extract
    AS
    hndl   NUMBER; --dbms_metadata handle
    th     NUMBER; --transform handle
    DDL    CLOB;   --individual clobs extracted from the database
    BEGIN
    hndl := DBMS_METADATA.OPEN ('DATABASE_EXPORT'); --Open the metadata
    DBMS_METADATA.set_filter (hndl, 'INCLUDE_PATH_EXPR', '=''DIRECTORY'''); --Filter data as appropriate
    th := DBMS_METADATA.add_transform (hndl, 'DDL'); --Get the Transform Handle
    DBMS_METADATA.set_transform_param (th, 'SQLTERMINATOR', TRUE); --Include the semicolon
    LOOP
    DDL := DBMS_METADATA.fetch_clob (hndl); --Loop through the result set, inserting into our temp table
    EXIT WHEN DDL IS NULL;
    INSERT INTO my_metadata
    (md)
    VALUES (DDL);
    COMMIT;
    END LOOP;
    DBMS_METADATA.CLOSE (hndl);
    EXCEPTION
    WHEN OTHERS
    THEN
    NULL;
    END;
    show errors
    I can't see the bit where you actually try to execute the procedure - I assume you are doing this.
    One killer feature of your code is the "when others then null" - you're not going to know where and why your code failed.
    Taking a guess: are you running this as SYS ? If not then it's possible that you're not finding any data because of some feature in the way that the code sees the directory objects - they're always owned by SYS.
    Although your code (when corrected) will generate the grants on the directories, the following is sufficient to generate the "create directory" statements. (Since all directories are owned by SYS it's actually an error to reference an owner in this query -- that means, by the way, that the answer you've marked as correct doesn't actually work).
    select
         dbms_metadata.get_ddl('DIRECTORY',directory_name)
    from
         dba_directories
    ;Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)
    +"I believe in evidence. I believe in observation, measurement, and reasoning, confirmed by independent observers. I'll believe anything, no matter how wild and ridiculous, if there is evidence for it. The wilder and more ridiculous something is, however, the firmer and more solid the evidence will have to be."+
    Isaac Asimov                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Cost Element Report for all cost objects

    Hello,
    Is there any standard SAP report where it can list down all cost elements, and their line item/total postings done to various CO Objects in one shot.
    We have CE/CCTR, CE/IO, etc, but if we can have one report which can list all cost elements and postings done via it to different cost objects - cost centers, internal orders, WBS, etc, might be very handy to us.
    Thanks
    Balla

    Hi Balla,
    Please use S_SL0_21000007 for your requirement.
    It gives cost element postings to different cost objects.
    regards,
    makrand

  • Get DDL for uncrypted packages using DBMS_METADATA

    Hi all,
    i was wondering if i could extract DDL sources for only uncrypted packages in my database using DBMS_METADATA?
    i have a lot of crypted packages stored in the DB.
    thank you in advance for your help

    dodi wrote:
    mmm so there is no way i can do that :( too bad!What about something like this (note untested)?
    DECLARE
    BEGIN
            FOR r IN
                    SELECT  DISTINCT OWNER
                    ,       NAME
                    ,       TYPE
                    FROM    DBA_SOURCE WHERE
                    NOT REGEXP_LIKE(UPPER(TEXT),'(PROCEDURE|PACKAGE|PACKAGE BODY) (.*) WRAPPED')
                    AND OWNER NOT IN ('SYS','SYSTEM','SYSMAN') -- Or OWNER IN for a specific set of SCHEMAS
                    AND TYPE IN ('PROCEDURE','PACKAGE')
                    AND LINE = 1
            LOOP
                    /*EXECUTE IMMEDIATE 'SELECT DBMS_METADATA.GET_DDL(''' || r.TYPE || ''',''' || r.NAME || ''',''' || r.OWNER || ''') FROM DUAL';*/
                    DBMS_OUTPUT.PUT_LINE('SELECT DBMS_METADATA.GET_DDL(''' || r.TYPE || ''',''' || r.NAME || ''',''' || r.OWNER || ''') FROM DUAL');
            END LOOP;
    END;

  • Anybody using a Citrix or VMware solution for all Oracle 11i clients/users?

    Hi,
    We are seeing a fair amount of browser issues in 11i so we are thinking of purchasing Citrix or Vmware and just have all users of Oracle go through this system instead of the browsers on their PC's. Does anybody do this now, and what are the advantages and disadvantages?
    The real chance we will do this is only about 50% - We recently eliminated Jinitiator and went to JRE, which is somewhat better, but at the same time the JRE is being updated fast and furious (e.g 1.6.0_22 came out yesterday, 21 did not have a long shelf life).

    Pl post details of EBS version.
    >
    We are seeing a fair amount of browser issues in 11i ...
    >
    Pl detail what these issues are. How would using Citrix eliminate or reduce these issues ?
    Oracle recommends that automatic JRE updates be disabled.
    Deploying Sun JRE (Native Plug-in) for Windows Clients in Oracle E-Business Suite 11i (Doc ID 290807.1)
    http://blogs.oracle.com/stevenChan/2010/07/warning_e-business_suite_issues_with_sun_jre_160_21.html
    http://blogs.oracle.com/stevenChan/2010/08/jre_6u21-b08_for_ebs.html
    HTH
    Srini

Maybe you are looking for