Script to create grants and synonyms for objects in database

Hello,
We are building a patch to be applied to the production environment. I want to create a script/sql query that builds a list of grants and synonyms for all the objects created after august 09.
for ex:
create or replace synonym abc for schema_name.abc;
Grant execute on abc to user_xyz;
How can I use Oracle's data dictionary to do this?
thankz

Hi,
You'll probably want to use these views:
user_objects - includes created (DATE) column.
user_synonyms
user_tab_privs - not just tables (e.g., includes EXECUTE privileges on functions).
Data dictionary views beginning with 'user_' cover objects owned by the current user only.
Almost all of the data dictionary views (and all of the three mentioned above) also have 'all_' and 'dba_' versions.
For example:
all_objects inculdes everything in user_objects, plus objects in other schemas on which the current user has privileges.
dba_objects include every object in the database. (Not everyone is allowed to see the dba_ views.)
Here's one of many possible ways to use these views:
SELECT     'GRANT '
||     privilege
||     ' ON "'
||     table_name
||     '" TO '
||     grantee
||     CASE
          WHEN  grantable = 'YES'
          THEN  ' WITH GRANT OPTION;'
          ELSE  ';'
     END
FROM     user_tab_privs
WHERE     table_name  IN (          -- Only interested in objects created after August 9
                 SELECT  object_name
                 FROM    all_objects
                 WHERE   created >= TO_DATE ( '10-Aug-2009'
                                                       , 'DD-Mon-YYYY'
;

Similar Messages

  • Error while running Re-create grants and synonyms for APPS schema

    Hi,
    I have upgraded customer's Oracle Apps 11i (11.5.10) database to Oracle 10g R2. While executing '+Re-create grants and synonyms+ ' as given in Note: 362203.1, I am gettng error:
    plus80 -s APPS/***** @E:\EBSTEST\ebstestappl\ad\11.5.0\admin\sql\adappsgs.pls &systempwd 1 INV APPLSYS APPS TRUE FALSE TRUE
    Error:
    Program exited with status 3
    Cause: The program terminated, returning status code 3.
    Action: Check your installation manual for the meaning of this code on this operating system.Connected.
    old 2: ad_apps_private.create_grants_and_synonyms(&2,'&3','&4','&5','FALSE');
    new 2: ad_apps_private.create_grants_and_synonyms(1,'INV','APPLSYS','APPS','FALSE');
    begin
    *+
    ERROR at line 1:
    ORA-20000: ORA-00955: name is already used by an existing
    object:create_grants_and_synonyms(1,INV,APPLSYS,APPS): create_base_gs(INV,APPS): In Synonyms
    Loop:create_synonym(INV,MTL_ONHAND_DISCREPANCY,APPS,MTL_ONHAND_DISCREPANCY):
    do_apps_ddl(APPS,CREATE SYNONYM "MTL_ONHAND_DISCREPANCY" FOR INV."MTL_ONHAND_DISCREPANCY"):
    ORA-06512: at line 5
    MTL_ONHAND_DISCREPANCIES
    I checked the database and there isn't MTL_ONHAND_DISCREPANCY synonym. But there is MTL_ONHAND_DISCREPANCIES synonym.
    This is an upgraded instance from 11.0.3 and first time I am running Re-create grants and synonyms for APPS schema.
    Plz let me know if anyone of you faced this issue.
    Rgds,
    Thiru

    Hi,
    there is no such table MTL_ONHAND_DISCREPANCY or synonym in Applications 11.5.10.2. Is that custom table created in your db?
    After dropping this table from APPS schema 'Re-create grants and synonyms for APPS schema' went thru fine.Its correct
    This table does not exist in INV schema in 11.5.10.2.
    Could be possible that the consultant could have created this table in INV and APPS schema by mistake or whatever.Yes, with the same name, there might be table in APPS SCHEMA. When you run recreate grants and synonyms, adadmin tries to create synonym for that table in APPS schema. since there is object available with the same name in apps chema, you got that error.

  • Error In Adadmin Re-Create Grants And Synonyms For Apps Schema

    HI,
    I upgraded the my DB from 9.2.6 to 10.2.4.It was sucessfull.
    While doing Postupgradayion steps -
    Recreate grants and synonym for apps
    a. Log in to server with applmgr user
    b. Execute adadmin
    c. Choose -> Maintain Applications Database Entities menu
    d. Choose -> Re-create grants and synonyms for APPS schema
    2 workers got failed ...
    i chked the worker log file i found
    sqlplus -s APPS/***** @/stageAPP/stageappl/ad/11.5.0/admin/sql/adappsgs.pls &systempwd 1 PO APPLSYS APPS TRUE FALSE TRUE
    Connected.
    old 2: ad_apps_private.create_grants_and_synonyms(&2,'&3','&4','&5','FALSE');
    new 2: ad_apps_private.create_grants_and_synonyms(1,'PO','APPLSYS','APPS','FALSE');
    begin
    ERROR at line 1:
    ORA-20000: ORA-00955: name is already used by an existing
    object:create_grants_and_synonyms(1,PO,APPLSYS,APPS): create_base_gs(PO,APPS):
    In Synonyms
    Loop:create_synonym(PO,XXGOD_SEQ_DECORTIMESHEET_HDR,APPS,XXGOD_SEQ_DECORTIMESHEE
    T_HDR): do_apps_ddl(APPS,CREATE SYNONYM "XXGOD_SEQ_DECORTIMESHEET_HDR" FOR
    PO."XXGOD_SEQ_DECORTIMESHEET_HDR"):
    ORA-06512: at line 5
    Workaround $adctrl
    Control
    Worker Code Context Filename Status
    1 Run Grants/Synonyms R115 adappsgs.pls FAILED
    2 Run Grants/Synonyms R115 Wait
    3 Run Grants/Synonyms R115 Wait
    4 Run Grants/Synonyms R115 Wait
    5 Run Grants/Synonyms R115 Wait
    6 Run Grants/Synonyms R115 Wait
    7 Run Grants/Synonyms R115 Wait
    8 Run Grants/Synonyms R115 Wait
    9 Run Grants/Synonyms R115 Wait
    10 Run Grants/Synonyms R115 Wait
    11 Run Grants/Synonyms R115 Wait
    12 Run Grants/Synonyms R115 Wait
    13 Run Grants/Synonyms R115 Wait
    14 Run Grants/Synonyms R115 Wait
    15 Run Grants/Synonyms R115 Wait
    16 Run Grants/Synonyms R115 Wait
    SQL> select owner, object_type from dba_objects where object_name = 'XXGOD_SEQ_DECORTIMESHEET_HDR';
    OWNER OBJECT_TYPE
    PO SEQUENCE
    APPS SEQUENCE
    Its Cutom Object .. I think i need to drop/rename anyone .. which one i should drop / rename .
    Or
    Is it possible to skip the failed workers .. if do .. please give me the steps ...
    Thanks

    Hi;
    There is 8 option(hidden) avaliable but i suggest dont use this option.(As you mention its a custom,if you belive it wont problem you can use this hidden option or drop 'XXGOD_SEQ_DECORTIMESHEET_HDR' and recreate it later,its own your risk) By the way please check below notes which is similar error like yours
    Run Adadmin To Recreate Grants And Synonyms ORA-20000 ORA-00955 In Synonyms Loop:create_synonym(GL,PLAN_TABLE,APPS,PLAN_TABLE) [ID 437714.1]
    ADADMIN MAINTAINING APPLICATIONS GRANTS AND SYNONYMS APP-931 ORA-955 ORA-20000 [ID 1014455.102]
    Regard
    Helios

  • Recreate Grants and Synonyms for APPS schema

    Hi,
    how can I Recreate Grants and Synonyms for APPS schema ?
    Many thanks.

    Hi,
    You can recreate grants and sysnonyms through adadmin utility.
    Navigation : adadmin - > Maintain Applications Database Entities menu - > Re-create grants and synonyms for APPS schema.
    Rgds,
    S.Jai
    Shanthi Gears (LTD)

  • Custom Transformations Scripts: Creating sequences and synonyms

    Is there a way in Data Modeler to script the creating process of sequences and synonyms. I've already found how to create columns in a table, but is it also possible to create sequences and synonyms for tables? I've looked it up in the XML Metadata, but I didn't found where I was looking for? Can anybody help me?

    no documentation, it should be possible:
    seq = model.getStorageDesign().getSequenceSet().createSequence();
    syn =  model.getStorageDesign().getSynonymSet().createSynonym();make sure physical model is open and that model is set as physical model to your relational model. That's for Oracle
    Philip

  • Do I need to reapply grants and synonyms. Altering Rename for other schema

    Hi,
    We are following the process to replace some tables in UAT/PROD with new structure of tables.
    So for example for Table A in Schema A:
    Step1- Create TableA_NEW with the required structure and partitions.
    Step2- Insert into TableA_NEW Select * from TableA.
    Step3- Alter Table TableA Rename to TableA_OLD --Take Backup of TableA
    Step4- Alter Table TableA_NEW Rename to TableA --Change the New table ti Original Table
    Now do I need to reapply all the grants and synonyms originally applied to TableA.
    When I test in Dev, all the grants and synonyms still hold. But I can't take any chances for UAT/PROD.
    Also when I rollback these changes and Rename the tables back to Original table.
    Then do I need to Reapply all the grants and synonyms originally applied to TableA.
    Please suggest..

    user8941550 wrote:
    Hi,
    We are following the process to replace some tables in UAT/PROD with new structure of tables.
    So for example for Table A in Schema A:
    Step1- Create TableA_NEW with the required structure and partitions.
    Step2- Insert into TableA_NEW Select * from TableA.
    Step3- Alter Table TableA Rename to TableA_OLD --Take Backup of TableA
    Step4- Alter Table TableA_NEW Rename to TableA --Change the New table ti Original Table
    Now do I need to reapply all the grants and synonyms originally applied to TableA.
    When I test in Dev, all the grants and synonyms still hold. But I can't take any chances for UAT/PROD.
    Also when I rollback these changes and Rename the tables back to Original table.
    Then do I need to Reapply all the grants and synonyms originally applied to TableA.
    Please suggest..
    Step1- Create TableA_NEW with the required structure and partitions. New table - does not have grants
    Step2- Insert into TableA_NEW Select * from TableA.
    Step3- Alter Table TableA Rename to TableA_OLD --Take Backup of TableA Renamed table keeps grants. Synonym not valid at this point
    Step4- Alter Table TableA_NEW Rename to TableA --Change the New table ti Original Table New table still does not have grants, synonym now valid
    So, grants disappear but synonym will be valid at end of process.

  • Create Synonym for Object Type not supported; Why?

    Does anybody know the reason why Oracle does not support the creation of synonyms for object types?
    In our application we use many schemas to separate subsystems. The schema name has a version identifier included to allow multiple product versions loaded in the database at the same time.
    We reference objects between schemas by using synonyms, to avoid hardcoding the schema names.
    Therefore I must refrain from using object types, currently.
    Does anybody have such a multi-schema architecture, also?
    What is your experience?
    Thanks,
    Robert

    Robert,
    Type synonym is now supported in Oracle9i Release 2. The practice of using multi-schema architecture is an excellent practice for large applications. This provides a level of abstraction to simplify application maintenance, whihc you must have experienced. In conjuction with Object types, you can further simplify your application through reuse of user-defined types.
    Do you have an email address that I can contact you for further discussion off-line.
    Regards,
    Geoff
    Does anybody know the reason why Oracle does not support the creation of synonyms for object types?
    In our application we use many schemas to separate subsystems. The schema name has a version identifier included to allow multiple product versions loaded in the database at the same time.
    We reference objects between schemas by using synonyms, to avoid hardcoding the schema names.
    Therefore I must refrain from using object types, currently.
    Does anybody have such a multi-schema architecture, also?
    What is your experience?
    Thanks,
    Robert

  • Create a public synonym for a db link - "Connection desccriptor not found".

    I want to create a public synonym for a db link.
    The existing db link name is tst.world ( which is in db links table and is working fine).
    I created the following db link using the following command:
    create public synonym "syn.world" for "tst.world";
    It created the synonym successfully.
    If I try the following, it throws error "Connection desccriptor not found".
    select * from [email protected];
    It says "Connection desccriptor not found".
    Any suggestions.
    Thanks in Advance.

    Well then, lookup the Documentation on the CREATE SYNONYM statement in the SQL Language Reference manual.
    The documentation lists the types of objects which you can create synonyms for.
    You can create synonyms for objects referenced across DBLinks.
    You cannot create synonyms for DBLinks.
    Hemant K Chitale

  • Creating Properties and Methods for an exe built in LabVIEW

    Hi all,
    How do we create properties and methods for an executable built in LabVIEW.
    I know when building an exe, the "Enable ActiveX server" option in advanced has to be enabled.
    But after that how do we create Properties and methods for the activeX component.
    Your help is greatly appreciated.
    Regards,
    Muthuraman S
    Regards,
    Muthuraman

    You cannot build your own COM specific properties and methods for the ActiveX interface in LabVIEW, the only thing exposed are the normal VI server properties and methods.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How to create credit and debit for an account

    Please tell how to create credit and debit for an account in currencies like EURO,GBP other than functional currency(USD).

    hi,
    You will find Dr and Cr entry for Both currencies which are functional & Transaction currency.
    Regards,
    Srikanth.Kura

  • How do I create a new emkey for Enterprise Manager Database Control?

    Hi,
    I just installed 11gR2.
    I am evaluating it.
    How do I create a new emkey for Enterprise Manager Database Control?
    I tried various combinations of this command:
    emctl config emkey
    I did find a probable bug:
    $ emctl config emkey -emkey -emkeyfile emkey.ora -force -sysman_pwd he11ow0rld
    Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0
    Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved.
    Undefined subroutine &EmKeyCmds::promptUserPasswd called at /u2/app/oracle/product/11.2.0/dbhome_1/bin/EmKeyCmds.pm line 160, <FILE> line 3.
    $
    Again,
    How do I create a new emkey for Enterprise Manager Database Control?
    I do have a copy of my old key but it is no longer good because I reinstalled the repository with these commands:
    emca -repos drop ...
    emca -repos create ...
    Oh, and where is emctl "documented".
    I poked around in some book-index links and with the search engine.
    I could not find anything.
    Thanks,
    -Janis

    user11892726 wrote:
    Oh, and where is emctl "documented".
    http://download.oracle.com/docs/cd/B16240_01/welcome.html

  • For preparing the filenames and paths for the oracle database files..

    Hi,
    I am preparing the filenames and paths for the oracle database files.....but I am not able to complete this one...Will you Please help for filling this one.
    Controlfile ---- > select name from v$controlfile;
    Redologfile -- > select member from v$logfile;
    Datafile --------- > select tablespace_name,file_name from dba_data_files order by 1;
    Tempfile --------> select tablespace_name,file_name from dba_temp_files;
    Spfile -----------> show parameter spfile
    Pfile --------------->
    Passwordfile ---->
    tnsnames.ora -->
    listener.ora------>
    sqlnet.ora ------>
    oratab ------------->
    Thanks
    Shiju

    orashiju wrote:
    Hi,
    I am preparing the filenames and paths for the oracle database files.....but I am not able to complete this one...Will you Please help for filling this one.
    Controlfile ---- > select name from v$controlfile;
    Redologfile -- > select member from v$logfile;
    Datafile --------- > select tablespace_name,file_name from dba_data_files order by 1;
    Tempfile --------> select tablespace_name,file_name from dba_temp_files;
    Spfile -----------> show parameter spfile
    Pfile --------------->spfile and pfile are located under $ORACLE_HOME/dbs/
    Passwordfile ----> passwordfile is located under $ORACLE_HOME/dbs
    tnsnames.ora -->
    listener.ora------>
    sqlnet.ora ------>all above files are under $ORACLE_HOME/network/admin
    oratab ------------->depends on operating system. Usualy under /etc/oratab

  • PS script to change printers and check for default

     We have a large project of renaming printers due to some linux devises that do not agree with our naming convention. I am new to ps so looking for some direction.
    Our current printers are say 'print$1' and we are changing to 'print1' basically just removing the dollar sign.
    We have batch files for the helpdesk for new imaged machines so they will get the new names, no problem but for the people that have been here, how can I create a script that will do the following:
    1. allow me to put old printer > replace with new printer
    2. detect if old printer is default and make new printer default.
    3. only affect the printers that are currently installed on the pc
    note we have multiple locations and alot of print servers. 
    thank you for your help

    gaff-
    I believe he wants to rename the printers on the client workstation. Group Policy can do that very easily
    You can also add to your ProintManager script to have it generate the GP objects and add the users or computers to them.  Most of the time is is easier to just use ProntManager GUI unless you have hundreds of printers  If it is only a dozedn then
    a non-scripter would be better off running the GUI.
    We moved about 30 printers for 100 accounts in about one hour the first time we set up PrintManager.  This included an upgrade to 64 bit drivers which was the biggest issue. A rename is very much easier.  I can rename 30 probters with the GUI in
    about 2 minutes.
    It is resetting the client systems that is the issue.  If they are beoing set by GP or through a login script then this, too, is easy.  If they are just attached in different ways then I recommend that Group Policy is the only way to reset them
    without spending a month trying to design a script that will work for all systems.
    If this is for a WS2003 spooler then you can still use Group Policy Preferences it you install the AD updates or have WS2008 domain controllers.
    Placing all printers under PrintManager control is the absolute best method.
    If all printers are not Windows printers - (Unix spolers or JetDirect/Network) then you will have to create a script that can find every pronter and rename it on every system.  This will be very difficult to do and will likely take quite a while to
    accomplish in a large network.
    GP can install printers at the machine level and update drivers.  This will work well except if you are using non-Windows compliant printers.  I have never had this scenario work smoothly on  an older network.  This is one reason why
    I do everything I can to force Admins to use PrintManager for all printers WIndows and Unix.  We also try to be sure the location awareness is enabled and that all locations are tagged in AD.  This allows users to browse easily for local and remote
    printers.  We set initial default but user4s are always allowed to change the default if they want and know how.  Users are allowed to print to all "group" printers and departmental printers but not to personal printers.  In some cases
    all users in a group can print to each others personal printers.
    I am now working on getting wireless printers set up for use by visitors, guests and salespeople.  Every group should have a wireless printer and know the hidden SSID.  I notice that many universities and hospitals are now doing this for the convenience
    of visitors. I can priont from my phone almost everywhere I go lately.
    Use PrintManager.  It will save you a lot of trouble.  Once set up PowerShell can script everything very nicely.  Gaff's code will always be the easier way to do most things.
    If you look in the repository/Gallery you will see many PowerShell PrintManger scripts and tools. -
    I should also note that Gaff's suggestion to use WMI will only work in a login script and will not work well on system connected printers which will have to be done remotely.  Again, it all depends on how your environment is set up.
    ¯\_(ツ)_/¯

  • Event CREATED is not triggered for objects of type USER

    Dear all,
    I'm currently configuring a workflow, which should be started when new user account is created. I took event CREATE for object type USER as a start event, but the workflow does not start, when I create new user account via transaction code SU01. If I test workflow in SWUS, everything works fine. I checked the event trace, but it shows no records for events triggered when I use SU01 and create a user.
    Could you please advise how I can activate triggering of this event without using ABAP-developed event trigger?
    Thank you in advance.

    but here the requirement is to trigger workflow after the user account is created in the system.
    One more way to trigger a workflow is by the messages output. I mean when a user account is created successfully then a message will displayed on the screen let say User ABC created Successfully right so, when ever this message is raised then you can start the workflow by using this message. this can be done by using the txn SWUY
    1. Open SWUY txn.
    2. Click on Continue  and in the next screen give the area as the message class name from which the message is getting triggered and its number in the field Message and click on continue.
    3. Then it will open the PFTC txn mention the description and click on the workflow builder button and design the workflow as per you requirement.
    and once this is done , so when ever the message from the above mentioned message class is raised at that time your workflow will also be started.
    In this way I hope you can reduce your development time , searching for the right BADI or User exit and implementing the code and testing..
    Here in the above txn all you have to make sure that from which message class the message is getting displayed once the user is created successfully, I suggest you a way is you create a dummy user and once the dummy user is created succeffully system will display the message right?, so just double click on the message at the bottom of the screen this will let you knwo what is the message class and number it is using. and once you know tyr to approach the above steps....

  • Difference in storage method for DMS and Services for Object

    Hi-
    Our R/3 version is: 4.7 Enterprise.
    In most (if not all) of the transactions users execute, there is a feature where they can attach a file using "Services for Object" from their PC to the associated record (i.e. material master, purchase orders, service notifications, etc.) 
    What I would like to know is where the document is stored.  From what I found on help.sap.com it says that it is a link from the user's PC.  But I would guess it is storing a copy of the file as a blob on the R/3 server somewhere.  Is this true?  Or is there a risk if the user's harddrive dies, that the file is no longer available for viewing? 
    I am trying to determine the difference between using the Services for Object feature vs. DMS and setting up an object link for the specific object type (i.e. material).
    Thanks!
    -Jenn

    I found the following about Services for Objects: 
    Business Workplace
    The documents that were appended to an object using Create attachment and Create note are stored in the Business Workplace. There, for example, you can make settings for where the documents should be stored (R/3 System or Web Server) and which document classes may be loaded in the SAP System (for example DOC, but not EXE).
    Sending is also carried out internally using the Business Workplace. Messages are created that contain a link to the object as an attachment. By double-clicking on the attachment, the users can call the default method of the object. This is normally the display method.

Maybe you are looking for

  • Windows Server 2003 and Microsoft Assessment and Planning tool (MAP)

    Preparing for the end of support for Windows Server 2003 (4/2015) and the need to migrate from Windows Server 2003, I have been directed on several sites run the Microsoft Assessment and Planning tool (MAP) to aid in identifying any software and hard

  • How can I get Illustrator CS6 to update? I get Installation error code U44M1P7

    I have a windows 8.1 machine.  When I installed Design Standard CS6, I got error messages for Illustrator CS6,  Photoshop CS6 regular and Photoshop CS6 64-bit. I checked for Adobe updates, and after installing all of these, I still get an error for I

  • Why won't my Mac Book Pro shut down?

    My Mac Book pro isn't shuttting down. I've clicked the apple icon on the left > shutdown. But nothing happens it just shows this rainbow wheel for a few  seconds. I can't also control my volume and screen brightness with my keys any more and system p

  • Authorization report cats_da

    Hi, The authorization report CATS_DA working with my client in such a way where my client is getting report on the employees working under him but he requires his name to be included in the report. regards amar

  • Invoice cancellation issue!!

    Hi All, I have a inovice cancellation issue. A PO was created in the year 2007 & an inovice was posted for the same. The tax rate at that time, when the PO was created & the invoice posted was 6% but now the tax rate is 5% and when I try to cancel th