Private Synonyms Referencing

Question in my text asks
13. A private synonym:
A. Can be seen by any user in the database who has privileges on it and has privileges on the
synonym’s underlying object.
B. Can only be seen by the user who creates it, and cannot ever be seen by any other user in
the database under any circumstances.
C. Is created with the CREATE PRIVATE SYNONYM statement.
D. Is also called a “column alias” in a SELECT statement.
Anser is A.
My question is can't you grant privileges on the private synonym alone in order for it to be 'seen' by the given user.
I mean normally you would grant a table privilege to a user, then create a synonym for it. What if we just created a synonym and granted privileges on the synonym without granting access to the table. Can't the user still see the synonym, without being able to query the table..?

When you grant a privilege on a private synonym to a user oracle actually grants privilege to the underlying object itself. Just create a synonym and grant select privilege to some user for that synonym and then check the user_tab_privs for the granted user.

Similar Messages

  • Private synonym created on  table not working in function

    hi,
    I have created a private synonym on a table.
    now i am trying to create a function below is the code of the same.
    FUNCTION party_name(p_cntr_id NUMBER)
    RETURN VARCHAR2 AS
    v_cust_name VARCHAR2(100);
    v_cust_no varchar2(100);
    BEGIN
    select occ.cust_no
    into v_cust_no
    from ops_cust_cntr occ
    where occ.ID = p_cntr_id;
    SELECT party_name
    INTO v_cust_name
    FROM hz_parties -- this is the table on which synonym is created .
    WHERE party_id = v_cust_no;
    RETURN (v_cust_name);
    EXCEPTION
    WHEN OTHERS THEN
    RETURN NULL;
    END party_name;
    it is giving the message
    SQL> sho errors;
    Errors for FUNCTION PARTY_TEST:
    LINE/COL ERROR
    12/1 PL/SQL: SQL Statement ignored
    14/6 PL/SQL: ORA-00942: table or view does not exist
    but when i run
    SELECT party_name
    FROM hz_parties;
    it is giving me the data.
    Please advice.
    Regards
    Sudhir.

    This has nothing to do with the synonym.
    Look at this:
    SQL> create table t1 (c1 number);
    Table created.
    SQL> create synonym test_tab for t1;
    Synonym created.
    SQL> create or replace procedure p1 as
      2    l_count pls_integer;
      3  begin
      4    select count(*)
      5    into   l_count
      6    from   test_tab;
      7    dbms_output.put_line(l_count || ' records found.');
      8  end;
      9  /
    Procedure created.
    SQL> exec p1
    0 records found.
    PL/SQL procedure successfully completed.
    SQL> I guess, you don't have the select privilege on this table.
    Remember: The privileg must be granted directly to the user who is the owner of the procedure/function/package. Privilege through a role are not valid inside the procedure/function/package.

  • Expdp / impdp - Private synonyms using DB link not imported

    Hi
    I'd appreciate any help with this.
    We are taking an export (expdp) of a database on Oracle EE 10.2.0.3 in Prod and then importing it into an identical DB on 10.2.0.5 in Dev.
    I doubt the minor version difference is an issues, but I mention it for completeness.
    Our expdp in prod used to look like this:
    expdp agdba/x directory=DATA_PUMP_DIR dumpfile=X.DMP logfile=X.LOG schemas=A,B,C,D
    We have changed it to:
    expdp agdba/x directory=DATA_PUMP_DIR dumpfile=X.DMP logfile=X.LOG full=y EXCLUDE=SCHEMA:"IN ('E', 'F')"
    ( so basically do a full export, but exclude schemas E & F )
    The impdp in dev has not changed (we import one schema at a time):
    impdp agdba/x DUMPFILE=X.DMP LOGFILE=imp_X.LOG SCHEMAS=A DIRECTORY=DATA_PUMP_DIR TABLE_EXISTS_ACTION=SKIP
    DB user AGDBA has been granted the DBA role...
    The Issue:_
    Private synonyms that use a DB link are NOT imported, but private synonyms that do NOT use a DB link ARE imported.
    I can fix the issue by simply recreating the private synonyms using the DB link - e.g.:
    CREATE SYNONYM EVENTLOGTBL FOR EVENTLOGTBL@FCISTOSMS;
    Things were working fine until we change the expdp to use FULL. I see a few posts about synonyms and FULL=Y issues, but nothing quite like our problem.
    Any ideas?
    Thanks,
    Andreas

    Andreas Hess wrote:
    So the problem is expdp FULL=Y for some reason does not export synonyms that refer to objects via DB links. I doubt that ... More than few times a week I refresh non-prod databases from a prod db, (it is schema level export not FULL=Y), and two of the schema own db links, and others have synonyms pointing to them. I have never encountered synonym problem (except that if db_links are invalid then impdp takes extremely long time to timeout while compiling pl/sql code.). We normally change db_links after the impdp is done, or (while it is importing table via another session).
    I just re-ran sqlfile option with include=db_link,synonym option and i can see statements that create synonyms and create db links.
    However i think the order in which impdp runs might be the source of your problem ... see this
    Starting "ME"."SYS_SQL_FILE_SCHEMA_01":  ME/******** dumpfile=xxxx.%u.dmp directory=xxxx_exp schemas=schema1,schema2,schema3 sqlfile=schema.sql include=db_link,synonym
    Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM       <<<< Synonyms are created first
    Processing object type SCHEMA_EXPORT/DB_LINK               <<<< db_links come later
    Job "ME"."SYS_SQL_FILE_SCHEMA_01" successfully completed at 08:32:02So, it is conceivable that if you drop synonyms/db_links from your schemas before impdp, some synonyms will fail to create properly. This could be a version specific issue, mine is 11.2 and I don't see failures for synonym creation, i.e. no error messages while impdp. Next time you could try to drop objects except db_links and see if you still have the same issue.
    Raj

  • Complex use of private synonyms

    I need to write a create user script that sets up our database. for production this is easy, but for development and test it gest complicated.
    We have 1 user that contains all of our data tables.
    another user that has all our code and our logging data.
    In development I need to create sets so developers can have their own environment.
    So how do I make code_user_a only see code_user_b's data without changing code? I think can do this with private synonyms, but I am not sure how to do it.

    First off. Synonyms have not changed over the last few version, but we are in 10.2
    Second off the point of the question is that I do not want to put them each in their own schema, I want it to mirror production. This is where the complexity comes from. I also don't want to change code.
    In production we will have two schemas
    Schema 1: All the tables that contain application data that users will see
    Schema 2: All the code and the logging tables
    This is a fairly standard deploy and not that uncommon. However, it gets complicated in development because I can have multiple "sets" of
    Schema 1
    Schema 2
    For example, a Developer named Jim and a Developer named Bob need to have their own set of schemas to do testing. So I need
    Schema1_Jim
    Schema2_Jim
    Schema1_Bob
    Schema2_Bob
    I only want Bob's Schema2(which has code that uses data in schema 1) to see schema1_Bob and not Schema1_Jim.
    It is not uncommon to deploy with multiple schemas for security reasons. I have seen it required by SOX auditors because the group that deploys the code is different than the group that deploys the data and the auditors say they are not allowed to share passwords.
    This is my requirement and I have to deal with it. The question is what is the best way to handle it in development. Productoin is easy becuase there is only one set of privileges.
    DBMS_WM is a good suggestion for a simple system. However, we have code that adds and drops partitions that need to act on the other schema so it won't work/.

  • Can't view private synonyms in OWB 9.2.0.2

    Hi All,
    I have created a number of private synonyms in Schema A for objects that exist in Schema B. When querying these tables via SQLPLUS (whilst in Schema A) I have no problems but I can not see these synonyms when trying an import in OWB (my Source module is connect to Schema A). I have checked the "Use a synonym to look up objects" checkbox but I still only see physical objects in my shema and not synonyms.
    Any help would be hugely appreciated.
    Kind Regards
    Mitesh

    I would like to add that I have created the synonyms in SchemaA for object in SchemaB across using a DB_LINK. When I create the synonyms without the use of a db_link I have no problems but when using it I do?

  • Private synonym working

    Hi,
    I have created a private synonym and granted a select privilege in one schema (webcen) as shown below, it is working fine,but the same thing is not working in another schema.
    CREATE SYNONYM HZ_LOCATIONS FOR OPERAPPS.HZ_LOCATIONS;
    connected to operapps and granted the below privilage.
    grant select on HZ_LOCATIONS to testsafe;
    it is showing the message PL/SQL: ORA-00942: table or view does not exist
    please advice.
    Regards
    Sudhir

    Hi Panela,
    i ahve done the below mentioned steps that are working fine.
    user:safex_dev
    schema : webcen
    owner of table :operapps
    synonym creation:
    CREATE SYNONYM HZ_LOCATIONS FOR OPERAPPS.HZ_LOCATIONS;
    privilege :
    grant select on HZ_LOCATIONS to safex_dev;
    i am following the below steps in another schema but it is not working.
    user:testsafe
    schema : oadtb
    owner of table :operapps
    synonym creation:
    CREATE SYNONYM HZ_LOCATIONS FOR OPERAPPS.HZ_LOCATIONS;
    privilege :
    grant select on HZ_LOCATIONS to testsafe;
    Please advice.

  • Private synonym unknown obj type

    Hi,
    I'm making a script, that makes private synonyms for the new database schema "ABC", for our existing schemas.
    part of the script is:
    SELECT * FROM (
         SELECT owner, object_name FROM all_objects WHERE owner IN ('ETL') AND object_type IN ('TABLE', 'VIEW') AND object_name NOT LIKE '%$%' MINUS(
    SELECT table_owner, table_name FROM all_synonyms WHERE UPPER(owner) IN ('PUBLIC', 'ABC')
    AND UPPER(table_owner) IN ('ETL'))
    r_synonym     sys.all_objects%ROWTYPE;
         FOR r_synonym IN table_synonyms
         LOOP
         EXECUTE IMMEDIATE 'CREATE OR REPLACE SYNONYM ABC.'||r_synonym.object_name ||' FOR '||r_synonym.owner||'.'||r_synonym.object_name;
         END LOOP;
    Now, the synonym gets created, but the info shows me "<unknown obj type>" and as you can expect, the synonym doesn't work (even though it's created).
    Any ideas?
    Thx

    Does ABC have any privileges on the objects?
    E.g. a sysnonym on a table will not work if you don't have a privilege like SELECT or UPDATE.
    Regards
    Marcus

  • Private synonym privileges

    Hello i am new to oracle.can anyone help me with this problem?
    I am able to create public and private synonym in main user 'system'
    But while creating the same in other users 'scott'
    1* create public synonym empdetails for emp
    SQL> /
    Synonym created.
    public synonym is created but while trying for private synonym
    SQL> CREATE SYNONYM empd for emp;
    CREATE SYNONYM empd for emp
    ERROR at line 1:
    ORA-01031: insufficient privileges
    Thanks in advance

    Your system privileges:
    select *  from USER_SYS_PRIVS
    -- related to synonyms
    select *  from USER_SYS_PRIVS WHERE PRIVILEGE like  '%SYNONYM%'If you don't have this privileges, you need to connect to another schema which can give scott this kind of privilege(you've already done in your first post from SYSTEM):
    grant create /*public*/ synonym to scottYou could start reading here:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/schemaob.htm#CNCPT711
    or
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_9013.htm#i2062318
    and
    http://wikis.sun.com/display/Forums/Forums+FAQ
    Edited by: zep111 on Apr 18, 2011 5:16 PM
    Ops. I've commented "public" in the grant.

  • Use of private synonyms for types breaks code

    Hi
    When using the following code snippet:
    =====================================
    OracleCallableStatement ocs = null;
    try {
    ocs = (OracleCallableStatement) conn.prepareCall("{ ? = call somemethod(?,?) }");
    ocs.setString(2, filter);
    ocs.registerOutParameter(1, Types.NUMERIC);
    ocs.registerOutParameter(3, OracleTypes.ARRAY, "SOME_TYPE");
    ocs.execute();
    ARRAY usersArray = ocs.getARRAY(3);
    Object[] structs = (Object[]) usersArray.getArray();
    We get an error when the registering of the type in the line
    ocs.registerOutParameter(3, OracleTypes.ARRAY, "SOME_TYPE");
    is done using a reference to a synonym rather than the direct name.
    The error occurs on the line
    Object[] structs = (Object[]) usersArray.getArray();
    We are using the 10.2.0.1.0 drivers against an 9.2.0.5 database.
    Any ideas are appreciated
    Leon

    Leon,
    I'm only guessing, but did you try setting the "includeSynonyms" [connection] property to 'true'?
    See the JDBC Developer's Guide and Reference for more details.
    Good Luck,
    Avi.

  • Performance Problem: Synonym in Schema Referencing Synonym in Diff Schema

    Does anyone have any experience using a synonym in one schema that references another synonym in another schema? I found that if I do it this way, the performance drops considerably depending upon the SQL. It runs slow and in some cases I get Oracle errors (i.e. Invalid ROWID). If I change my synonym to reference the actual table in the other schema, it don't get the same degradation in performance.
    I'm curious if anyone has experienced the same problem and what options might be available to improve the situation. I lose the "semantic" layer by doing this - having to always reference the physical table instead of the synonym in the other schema.
    Thanks for any input or comments you might have.
    Sabert

    Only 2 schemas. Schema A has a table T1 with a public synonym S1. I am running sql against Schema B, however I have a private synonym S2 in this schema (B) that references synonym S1 in Schema A. Because I am using a synonym to reference another synonym in another schema I'm having performance issues. I tried a test and changed the S2 synonym in schema B to point to the table T1 instead of S1 in schema A and it performed much better. Just want to understand what I'm seeing here. This example might help:
    Schema A:
    "CREATE SYNONYM S1 FOR T1"
    Schema B (I'm running my sql against this schema, but my synonym points to table in schema A):
    "CREATE SYNONYM S2 FOR A.S1"
    "INSERT INTO XXX SELECT * FROM S2"
    I had performance issues with this synonym to synonym, so I changed it to synonym to table:
    "CREATE SYNONYM S2 FOR A.T1"
    Again, with the change in reference from a synonym to the actual table, things seem to work better. Hope this makes sense.
    Thanks for your help.

  • Capture of synonyms from existing online oracle9i database

    Hello!
    I am a newbee in oracle designer .I need to Design capture the ERP application into designer repository.The story goes like this ::
    I am in a scenario where an ERP Application is running but without any documentation and configuration control.The Application is developed using Oracle10g Forms developer and reports,with backend oracle9i.The application and so database contains a lot of user schemas corresponding to the functional departments of organisation like finance , inventory.
    I have successfully Installed the repository (version control option enabled) on our online database('oratest') and created a repository owner 'desg',with DBA Priveleges.
    I have also created a database definition named 'oratest1' and a user named 'desg1' in the design editor's[b] System folder..
    I tried to capture the schemas in following sequence (using the option - Generate/Capture designof/servermodel). ::
    a. Login as Desg , Owner = sys-- Captured all tablespaces
    b. Login as Desg , Owner = desg-- Tried capturing designer objects but was not very successful
    c. Login as Desg , Owner = sys-- Tried capturing all sys objects , It took a lot of time with error and warnings and I was only able to capture some tables and views.I also tried with owner = 'System'.
    d Login as Desg , Owner = sys-- Captured all users from oratest to oratest1(errors displayed 'Invalid grants ')
    e. Login as Desg , Owner = sys-- Captured all roles from oratest to oratest1(errors displayed 'Invalid grants to user objects')
    f. Login as Desg , Owner = User schema1(say inventory) -- tried to capture relational tables,views,functions,procedures etc. A lot of errors saying that invalid references to objects i.e referenced objects not present in the repository.
    g. Noted down all dependencies using the DBA Views to user schema1 and captured corresponding objects from database into corresponding users in the repository.
    h. Login as Desg , Owner = User schema1(say inventory) -- Again tried to capture objects of this schema.It gives error that ' Cannot capture synonyms with same name as objects name, either recreate or make all of them public'.
    Following are my queries for which I need all your expert help::
    1. First of all ,is the sequence in procedure above alright ?.Is it necessary to capture 'SYS' , 'SYSTEM' Objects ..What if I have already done so,will it cause damage? If so is it is possible to remove them from repository automatically?.I captured since the user schemas refer to these objects at several places.
    2. Is it required to capture different User Schemas into different containers or just a single container ? If it is required to capture in different containers , how will tablespaces,users and roles already captured into system folder refer to objects in these containers.
    3.Regarding problem of grants : When are the 'grants' be captured,before the capturing the objects or after them or anytime.Is it required to capture grants via a DDL file . Will a text file generated by export grants option in 'Toad' tool will do the job?.
    4. Regarding Problem of capture of synonyms :: In most of user schemas , the private synonym has same name as the object which it refers.Hence designer is unable to capture the synonyms.If we make Synonyms public for a user schema than what about other schemas?. Secondly how to capture synonyms independently.Is it via a DDL File.Where in the design editor can we see the captured Synonyms?.How Shall we capture Public synonyms of our ERP application.
    5.In the server mode tab, under relational table definition,I can see all the mixture of user tables and sys tables.How can we isolate the tables as per user schemas and generate Server model Diagrams for individual schemas.
    Please help to resolve these Issues.
    Thanks
    With best regards

    Thanks For your reply.
    I am successful in capturing all other objects of the schema.
    Before Your reply and before capturing other objects, I tried to capture the private synonyms by first creating a ddl file and than modifying the SQL 's 'create synonym' statements to 'create public synonym', and than captured the public synonyms into the repository via design editor. In short I captured the private synonyms as public into the repository.It gave 0 error and 0 warnings.
    But where in the navigator pane can i see the captured synonyms. I cannot see any of them, so iam not sure whether they are captured or not.
    After this when I captured other objects , they were captured successfully without any errors.

  • AWM: Can not see the synonyms in the mappings pane

    Hi, using the AWM 11.2.0.1.0A, in the mappings pane under the item Synonyms does not appear any synonyms although there are some of them (private synonyms) in the user's scheme.
    Any hint?
    Thanks.

    I just tried this in 11.2.0.1 and the synonym showed up in AWM. I ran the following (in the sample GLOBAL schema)
    create synonym prod_table for product_dim;
    Note that product_dim is a table in the GLOBAL schema, and I ran the above statement as GLOBAL.
    I then attached AWM as GLOBAL and saw prod_table show up in the synonyms folder of the mappings pane. What are you doing that is different from this?

  • Use of synonyms in procedures

    In my procedure I need to select from a table in another schema. There is a public synonym for the table but I keep getting the compile error, 'Table or view does not exist'. I also tried making a private synonym with the same compilation results. I heard that in a procedure you can't select from a synonym but you can from a private one. Anyone know if that is true? Any suggestions?

    I heard that in a procedure you can't select from a synonym but you can from a private one.Horse feathers.
    What you actually got is permissions problems: we cannot build procedures (or views for that matter) on tables belonging to other users who have granted us privileges through a role. If you get user B to grant you SELECT or whatever directly to your user account you will be able to build your procedure.
    Cheers, APC

  • Import package (synonym) from db

    Hi,
    in our DWH we use a dedicated user (owbread) to read all data from all source databases . Tables are granted to this user in the source databases via synonym. The user does noown any tables , vies or packages himself.
    With tables this works fine. I can import them via obi and extract data in the etl processes.
    We want to do exactly the same with packages (and procedures or functions). We have created synonyms for the packages in the source database, but when we want to import the packages, we cannot see them in the import wizzard.
    Do we really need to copy these packages over to the data warehouse or how do we import them ?
    Regards,
    Knut
    P.S. OWB 11.1.0.7.0
    source db Oracle 9i
    Edited by: knherzog on 25.01.2011 02:16

    I faced the same problem long ago. may be you can raise a SR.
    the alternate is to create the location pointing to that schema.
    Unable to import private Synonym for procedure  in OWB
    Cheers
    Nawneet

  • How to use EXPORT  (user option)  ... IMPORT  for migrating ROLES and SYNONYMS

    Hi,
    I want to export a user from one machine to another one. And I have many roles and synonyms to migrate also. How to export / import them because when I import, I have only tables not roles and synonyms.
    Thanks.

    as far as I know, export doesnt export synonyms and roles.
    What I do is write sql scripts that create scripts to recreate all public synonyms, private synonyms, and roles.
    YOu want to roles created ahead of time anyway so that the import can do the grants.

Maybe you are looking for

  • Links to text items in context

    When I carry out a custom search, the results displayed can be linked to via the display name or image link. However, when the user clicks on the display name link they are directed to a page which displays the text item alone - out of context from t

  • Mapping buttons from imac Bluetooth Keyboard to Macpro

    I tried a friend's new mini bluetooth keyboard (one that sells with new imac) on my Macpro, and some of the buttons do not seem to map correctly. Example: volume was effecting expose. Is it just not meant to be used with anything other than an imac,

  • Older podcasts not showing on itunes

    Our school has made about 20 podcasts. However, only the last 7 or so are showing up on itunes. All are still on the web and available for download. Does anyone have any ideas? Thanks Randy

  • Oralce Price List - Order Management

    Hi, I am using OE_ORDER_PUB api to create Sales Order. I am loading all the data i the CUSTOM table and executing this api to create Sales Order. System successfully creating Sales Order. But, system is picking Sales Price from the price list used. F

  • Mac not listening to SSH port

    When I try to access the server remotely, it's giving me with an error: ssh_exchange_identification: Connection closed by remote host The firewall on Mac is disabled and all the traffic are allowed on my router to access the Mac from public IP. I'm u