Creating synonys for all table

i want to create synonyms for all atbles.the synonyn name and table name are same.instead creating one by one synonym i wnat to create all synonyms at a time.
1)select 'CREATE PUBLIC SYNONYM'||' '||'test'||' '||'for' ||' '||'test' from dual
2)select OBJECT_NAME from user_objects where OBJECT_TYPE ='TABLE'
in the first query if we replace with test with 2nd query then we can get the script for that.
i replaced that biut its not working how to do it

Here is a generic grant script. If you review it, you will see how it works and can adapt it to your varying needs.
BEGIN
    FOR x IN ( SELECT owner,
                      object_name,
                      DECODE(object_type, 'TABLE' ,   'select, insert, update, delete',
                                          'SEQUENCE', 'select',
                                          'VIEW',     'select',
                                                      'execute') AS privs,
                      DECODE (owner, 'SCHEMA_1', 'USER_1',
                                     'SCHEMA_2', 'ROLE_A'
                                      ) AS app_user
                 FROM dba_objects
                WHERE object_type IN ('TABLE',    'PACKAGE', 'PROCEDURE',
                                      'FUNCTION', 'SEQUENCE', 'VIEW')
                  AND owner       IN ('SCHEMA_1', 'SCHEMA_2' ))
    LOOP
      BEGIN
        EXECUTE IMMEDIATE 'grant ' || x.privs       || ' on ' || x.owner ||
                          '.'      || x.object_name || ' to ' || x.app_user   ;
        EXECUTE IMMEDIATE 'create or replace synonym '|| x.app_user||'.'||x.object_name||
                           ' for ' ||x.owner||'.'||x.object_name ;
      EXCEPTION
        WHEN others THEN
          dbms_output.put_line('Bad owner = '||x.owner||';  Bad app_user='||x.app_user||
                               ';  Bad object_name='||x.object_name);
      END;
    END LOOP;
END;
/

Similar Messages

  • Creating sequences for all tables in the database at a time

    Hi ,
    I need to create sequences for all the tables in my database.
    i can create individually ,using toad and sqlplus.
    Can any one give me a code for creating the sequences dynamically at a time for all the tables.
    it is urgent ..
    Regards.

    I need to create sequences for majority of the tables that are having ID column
    which is sequences."The majority" is not the same as all. So you probably want to drive your generation script off the ALL_TAB_COLUMNS view...
    where column_name = 'ID'You need to think about this carefully. You might want different CACHE sizes or different INCREMENT BY clauses for certain tables. You might even (whisper it) want a sequence to be shared by more than one table.
    Code generation is a useful technique, but it is a rare application where one case fits all.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Creating SYNONYM for all tables who don't have one at once!

    Hello to all,
    I'm trying to create synonyms for every table who's missing one at the moment. I'm trying this code:
    declare
    cursor cur_objects is
    select obj.object_name , obj.owner
    from all_objects obj
    where owner = '&&SCHEMA_OWNER'
    AND NOT EXISTS (SELECT *
    FROM all_synonyms syn
    WHERE obj.object_name = syn.table_name)
    AND obj.object_type = 'TABLE'
    AND obj.object_name LIKE 'CI_%';
    begin
    for rec_objects in cur_objects loop
    begin
    dbms_output.put_line(rec_objects.object_name);
    execute immediate('create public synonym ' || rec_objects.object_name || ' for '
    || rec_objects.owner ||'.'||rec_objects.object_name )
    exception when others then
    null;
    end;
    end loop;
    end;
    I'm getting this error:
    ORA-06550: line 10, column 37:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    begin function package pragma procedure subtype type use
    <een ID>
    <een scheidingsteken-ID tussen dubbele aanhalingstekens> form
    current cursor
    I'm still pretty new at PL/SQL and can't get it to work. Does anyone got any tips ?
    Thnx already

    Ok now I got this error:
    RA-06550: line 17, column 1:
    PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem return
    returning <een exponent (**)> <> or != or ~= >= <= <> and or
    like LIKE2_ LIKE4_ LIKEC_ between into overlaps using ||
    multiset bulk year DAY_ member SUBMULTISET_
    The symbol ";" was substituted for "EXCEPTION" to continue.

  • Script to create synonyms for the tables of Oracle Applications

    Team,
    For Oracle Applications 11i on W2K, where might I find a script to create synonyms for all of the application tables? I would think there would be a standard script somewhere in one of the directories created during the install or on the CDs.
    Thanks,
    Luther

    John, it is ssome sort of a bleed, but in this case it's not the part that 'might be cut off' that matters; it's the part that still needs to be on the page. Yes, I meant it to be (virtually) not-noticeable for the casual reader. Of course you can make it part of the page design, that ought to ease up matters.
    The amount pages shift horizontally because of binding is called "creep", and this depends on the type of binding and the thickness of the paper. You cannot adjust for creep unless you know exactly how much this is and how your book is going to be printed and bound.
    Airkite:
    But the book that you printed worked out alright? Was it done with a different method?
    This was a simple outlined text, not an image. Through the inaccuracies of printing and binding combined, there were no straight edges *anywhere* but fortunately the lines were thick enough to let you mentally connect them
    This was done (I'm sure) with the method you proposed.
    There is an alternative way, but it's way more expensive (on the other hand, the result is impressive): after the entire process of printing, binding, and cutting, books are put in a clamp one at a time and fed through a silk screen printer, fore edge on top, and printed with whatever you like.
    I know of the existance of this technique but I haven't seen a book done like this in years and have no clue at all of the costs involved (writing that down in one sentence makes me realize those two might be connected).

  • How do I run sp_spaceused for all tables in a database?

    Hi,
    I am struggling to understand how to run the sp_spaceused sproc for all tables in a database.
    I know how to use it for one table but how would I replicate it automatically for each table in a given database?
    Regards,
    Ian.

    I just managed to alter the code of VidyaSagar and have pulled out all the information including Schema name. Below is what it looks like:
    set
    nocount
    on
    select
    'Database Name: ',
    db_name
    if
    exists(select
    name from tempdb..sysobjects
    where name='##tmp'
    drop
    table ##tmp
    create
    table ##tmp(TABLE_SCHEMA
    nvarchar(256),TABLE_NAME
    nvarchar(256),
    num_rows int,
    reserved_KB varchar(15),data_KB
    varchar(15),index_KB
    varchar(15),unsed_KB
    varchar(15
    go
    declare
    @tbl_schema nvarchar(256
    declare
    @tbl_name nvarchar(256
    declare
    @schema_tbl_name nvarchar(256
    declare
    tblname CURSOR
    for
    select
    TABLE_SCHEMA
    TABLE_NAME
    from
    INFORMATION_SCHEMA.TABLES
    where TABLE_TYPE='BASE
    TABLE' 
    open
    tblname
    Fetch
    next
    from tblname
    INTO @tbl_schema,@tbl_name
    WHILE
    @@FETCH_STATUS
    = 0
    BEGIN
    set @schema_tbl_name=@tbl_schema+'.'+@tbl_name
    insert
    into ##tmp(TABLE_NAME
    , num_rows
    , reserved_KB
    ,data_KB
    ,index_KB
    ,unsed_KB
    exec
    sp_spaceused
    @schema_tbl_name
    update ##tmp
    set TABLE_SCHEMA
    =@tbl_schema
    where TABLE_SCHEMA
    is
    NULL
    and TABLE_NAME=@tbl_name
    FETCH
    NEXT
    FROM tblname
    INTO @tbl_schema,@tbl_name 
    END
    CLOSE
    tblname
    deallocate
    tblname
    go
    select
    from
    ##tmp
    drop
    table ##tmp
    Warm Regards, Ajay

  • What is authorization object and how to create it for a table

    Hi All,
    What is authorization object and how to create it for a table?
    Thanks

    Hi
    Authorization
    For authorization checks, there are many ways of linking authorization objects with user actions in an SAP system. The following discusses three possibilities in the context of ABAP programming.
    Authorization Check for Transactions
    You can directly link authorization objects with transaction codes. You can enter values for the fields of an authorization object in the transaction maintenance. Before the transaction is executed, the system compares these values with the values in the user master record and only starts the transaction if the appropriate authorization exists.
    Authorization Check for ABAP Programs
    For ABAP programs, the two objects S_DEVELOP (program development and program execution) and S_PROGRAM (program maintenance) exist. They contains a field P_GROUP that is connected with the program attribute authorization group. Thus, you can assign users program-specific authorizations for individual ABAP programs.
    Authorization Check in ABAP Programs
    A more sophisticated, user-programmed authorization check is possible using the Authority-Check statement. It allows you to check the entries in the user master record for specific authorization objects against any other values. Therefore, if a transaction or program is not sufficiently protected or not every user that is authorized to use the program can also execute all the actions, this statement must be used.
    AUTHORITY-CHECK OBJECT object
                            ID name1 FIELD f1
                            ID name2 FIELD f2
                            ID namen FIELD fn.
    object is the name of an authorization object. With name1, name2 ... , and so on, you must list all fields of the authorization object object. With  f1, f2 ... , and so on, you must specify the values that the system is to check against the entries in the relevant authorization of the user master record. The AUTHORITY-CHECK statement searches for the specified object in the user profile and checks the useru2019s authorizations for all values of f1, f2 ... . You can avoid checking a field name1, name2 ... by replacing FIELD f1  FIELD f2 with DUMMY.
    After the FIELD addition, you can only specify an elementary field, not a selection table. However, there are function modules available that execute the AUTHORITY-CHECK statement for all values of selection tables. The AUTHORITY-CHECK statement is supported by a statement pattern.
    Only if the user has all authorizations, is the return value sy-subrc of the AUTHORITY-CHECK statement set to 0. The most important return values are:
    ·        0: The user has an authorization for all specified values.
    ·        4: The user does not have the authorization.
    ·        8: The number of specified fields is incorrect.
    ·        12: The specified authorization object does not exist.
    A list of all possible return values is available in the ABAP keyword documentation. The content of sy-subrc has to be closely examined to ascertain the result of the authorization check and react accordingly.
    REPORT demo_authorithy_check.
    PARAMETERS pa_carr LIKE sflight-carrid.
    DATA wa_flights LIKE demo_focc.
    AT SELECTION-SCREEN.
      AUTHORITY-CHECK OBJECT 'S_CARRID'
                      ID 'CARRID' FIELD pa_carr
                      ID 'ACTVT' FIELD '03'.
      IF sy-subrc = 4.
        MESSAGE e045(sabapdocu) WITH pa_carr.
      ELSEIF sy-subrc <> 0.
        MESSAGE e184(sabapdocu) WITH text-010.
      ENDIF.
    START-OF-SELECTION.
      SELECT  carrid connid fldate seatsmax seatsocc
        FROM  sflight
        INTO  CORRESPONDING FIELDS OF wa_flights
        WHERE carrid = pa_carr.
        WRITE: / wa_flights-carrid,
                 wa_flights-connid,
                 wa_flights-fldate,
                 wa_flights-seatsmax,
                 wa_flights-seatsocc.
      ENDSELECT.
    Regards
    Hitesh

  • POV-After creating Tcode for a table SM30 I want F4 Help here

    Hi All,
    After creating Tcode for a table, When I am trying to give table entries thro' this Tcode, I want F4 help for those fields. Apart form assigning "Fixed values" in Domain level how can I achieve this.
    Points Assured.
    Regards,
    Suresh

    Hi,
          You need to create search helps based on this table for each filed or one for all the fields with proper import and export paramters. Or else you can give check table entries for each of the table fields for which you need the F4 help. Check table us assigned to a field using the Foriegn key assignment.
    Best Regards,
    Sesh

  • When do I really need to create indexes for a table?

    Once I was talking to a dba in a conference.
    He told me that not always I have to create indexes for a single table, it depends of its size.
    He said that Oracle read registers in blocks, and for a small table Oracle can read it fully, in a single operation, so in those cases I don't need indexes and statistcs.
    So I would like to know how to calculate it.
    When do I really need to create indexes for a table?
    If someone know any documment that explain that, or have some tips, I'd aprecciate.
    Thanks.
    P.S.: The version that I'm using is Oracle 9.2.0.4.0.

    Hi Vin
    You mentioned so many mistakes here, I don't know where to begin ...
    vprabhu_2000 wrote:
    There are different kinds of Index. B-tree Index is by default. Bit map index, function based index,index organized table.
    B-tree index if the table is large This is incorrect. Small tables, even those consisting of rows within just one block, can benefit from an index. There is no table size too small in which an index might not be benefical. William Robertson in his post references links to my blog where I discuss this.
    and if you want to retrieve 10 % or less of data then B-tree index is good. This is all wrong as well. A FTS on a (say) million row table could very well be more efficient when retrieving (say) just 1% of data. An index could very well be more efficient when retrieving 100% of data. There's nothing special about 10% and there is no such magic number ...
    >
    Bit Map Index - On low cardinality columns like Sex for eg which could have values Male,Female create a bit map index. Completely and utterly wrong. A bitmap index might be the perfect type of index, better than a B-Tree, even if there are (say) 100,000 distinct values in the table. That a bitmap index is only suitable for low cardinality columns is just not true. And what if it's an OLTP application, with lot's of concurrent DML on the underlining table, do you really think a bitmap index would be a good idea ?
    >
    You can also create an Index organized table if there are less rows to be stored so data is stored only once in index and not in table. Not sure what you mean here but an IOT can potentially be useful if you have very large numbers of rows in the table. The number of rows has nothing to do with whether an IOT is suitable or not.
    >
    Hope this info helps. Considering most of it is wrong, I'm not sure it really helps at all :(
    Cheers
    Richard Foote
    http://richardfoote.wordpress.com/

  • How can I resize and reposition the Date Created window for All windows?

    When setting view options for a finder window set to list view, I cannot get column resizing or positioning to hold. When making those changes, the option for "All Windows" automatically shifts to "This window only" and it then does not hold.
    How can I resize and reposition the Date Created column for All WIndows?

    Hi Harmz,
    Try dragging this file to the Îesktop & reboot...
    /Users/YourUserName/Library/Preferences/com.apple.finder.plist

  • How to create index for particular table in R3

    Hi
    My load is taking too much time and it leads to process over due error. Does creating indexes on table in r3 side will solve this issue? If so how can we find out on which table does this particular data source depend. I went to maintain extract structure and findout only one table is supplying data for this data source.
    Is there any other factors depend to solve this.
    Thanks
    kk

    Hi,
    it will depend on the table.... Having an index created will speed up the loading but slow down the insert therefore slowing some process perhaps...
    May I ask which table it is? And which fields would you need to index?
    Are you sure that bottleneck is located in R/3? Analyze your loading time in the monitor and see if this is really the case.
    Otherwise you can create index for a table in Tx SE11; first check if an index is not already created...
    hope this helps,
    Olivier.

  • How to create view for xmltype table in oracle

    hi:
    Can some one help me how to create view for xmltype table in oracle?
    XMLType do not have column
    Sem

    Thank you !!
    I read it and become very hard to implement what I want to do.
    Can you give me example please?
    My main goal to create view for xmltype table is to XQuery the XML data?
    Do you have any other suggestion?
    Please help
    Ali_2

  • Extract schema/metadata - names for all tables and attributes

    Hi, I am quite new to Oracle DB (only been doing dev mostly with sqlserver before). Is there a way to extract schema (names for all tables and attributes) for 10g and 11g in application code (either java or .net) or pl/sql?
    Thank you,
    -Tony

    There are built in views that start with DBA_, ALL_, and USER_. All means all the user can see, user means all the user has, and dba means everything, which generally means the same as the others plus an owner. So you can desc user_tables to see what-all that view has, then select columns from the view with ordinary sql. See the doc set for all the views available, interesting ones are ...views, ...objects, ...tab_cols and so forth.
    There are also built in procedures for getting metadata, google for details.
    Many tools have easy GUI's for this too. EM has ways on the administration screen to get to various objects, and then you can show the ddl. Maybe sqldeveloper has something too.

  • How to create gpo for all users in all ou?????

    hello,plz help me.i want to create gpo for all users in all ou.but i dont want that gpo to do in domain????

    Can you elaborate what you mean by "but i dont want that gpo to do in domain"?
    In terms of applying it to all users, that's simple enough, you can simply leave the GPO's security filtering with its default setting as "Authenticated Users" which then apply to everyone.
    In terms of it applying to all OUs, you only have two options.
    1) Create the GPO and link it to the root of your domain, so it then applies to the entire domain and all the OUs within it.
    2) Create the GPO, but instead link it to each OU that you want it to apply to. You can apply one GPO to as many OUs as you want, simply right click on the OU and select "Link an Existing GPO...". It's then not applied to the root of the domain, only the
    OUs, but any changes you make to the GPO are applied to all the OUs that you've linked it to (rather than having a separate GPO for each of them).

  • Create schedulers for all existing user jobs

    Hi Forum,
    In my database (Oracle Database 10g Enterprise Edition Release 10.2.0.4.0), I have 7 DB schemas.
    There are total existing 50 jobs (usaer_jobs).
    I want to shift them all to scheduler (user_scheduler_jobs).
    My plan is,
    1.     Create schedulers for all existing user jobs.
    2.     Enable all schedulers.
    3.     Disable all jobs.
    Is there any way / method for such shifting? I am ready to this exercise schema wise at a time.
    How to create scripts for creating schedulers from existing jobs?
    Thank you & regards..

    PROCEDURE CREATE_JOB
    Argument Name               Type               In/Out Default?
    JOB_NAME               VARCHAR2          IN
    SCHEDULE_NAME               VARCHAR2          IN
    JOB_TYPE               VARCHAR2          IN
    JOB_ACTION               VARCHAR2          IN
    NUMBER_OF_ARGUMENTS          BINARY_INTEGER          IN     DEFAULT
    JOB_CLASS               VARCHAR2          IN     DEFAULT
    ENABLED               BOOLEAN           IN     DEFAULT
    AUTO_DROP               BOOLEAN           IN     DEFAULT
    COMMENTS               VARCHAR2          IN     DEFAULT
    CREDENTIAL_NAME          VARCHAR2          IN     DEFAULT
    DESTINATION_NAME          VARCHAR2          IN     DEFAULTdoes not appear to be an available option.

  • Want to take "CREATE script" for all roles existing in DB.

    Hi All,
    I want to take "CREATE script" for all roles existing in DB.
    Please provide me script to generate if you have or suggest any link or doc.
    Oracle 10G

    Use this-
    select 'select dbms_metadata.get_ddl(''ROLE'','''||ROLE||''')||chr(10)||''/'' from dual;'
    from dba_roles
    Please be aware grants will not come in the definition
    If you like the answer then don't forget to give points

Maybe you are looking for

  • Welcome to the Voice and Video over WLAN Discussion

    Welcome to the Cisco Networking Professionals Connection Wireless Forum. This conversation will provide you the opportunity to discuss issues surrounding Voice and Video over WLAN. We encourage everyone to share their knowledge and start conversation

  • Why is my Macbook Pro running so slow when returning from sleep mode?

    I got my new Macbook this past Christmas so it is about two months old. I have the 13" Macbook with the standard 4GB of RAM (not sure if that matters), but when I got my mac I downloaded a bunch of games and such which may have slowed it down initial

  • Why the server for registration doesn't work now ?

    i try to register my iphone 4s and after 3 minutes when tryies to make the activation says your iphone coudn't be activated because the server for activation is temporary stoped. :|

  • Example program - posting accounting document,  Idoc ( ACC_DOCUMENT )

    Hi fellows developers, here is an example of  usage of the IDOC, directly in program for an accounting document (ALE message type ACC_DOCUMENT, bapi BAPI_ACC_DOCUMENT_POST )). It was inspired  by the lack of a flexible usage of this IDOC in LSMW (f.e

  • Sdovis No spatial data to render Error

    I just got map builder, and was able to see the geometries in a few of my tables, but when i tried to preview a table with over 3 million points, i got the above error. thanks for the help-