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/.
Similar Messages
-
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
LeonLeon,
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. -
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,
AndreasAndreas 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 -
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
MiteshI 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?
-
How to configure DPM2012R2 to use a private cloud
Hi,
I have configure a private cloud over several MS 2012 R2 servers. I have the storage and all required network done. I then installed DPM 2012 R2 and would like to use the "long term" storage function with the private cloud that I created. Has anyone
managed to get this done? The options in DPM 2012 R2 seems to only allow cloud association with Azure. Is it even possible to configure DPM 2012 R2 to use a private cloud deployment?
Any help with this will be greatly appreciated.
Kind RegardsThanks for the reply:
How would I be able to do any of the long term storage to disk with second DPM?
My scenario is as follow:
Primary DPM server is onsite with shortterm backup configured to disk. There are several protection groups to allow for different kinds of backup scenarios ie different times, different types of clients, etc. Then there is a "offsite" dpm server with about
40Tb available storage that I'd like to use as a "long term" storage for the currently protected groups. However I'm not extremely proficient with DPM and therefore I'm uncertain how to get this done.
What needs to be achieved is:
Onsite I'd like to keep 14days (currently configured to do so, so no change required)
Offsite I'd like to keep 12months (1 per month for each month) as well as 1 per year for 2 years of all protected groups.
The offsite DPM server has thusfar only been configured as Server 2012 r2 Std and the storage has been allocated to the private cloud. This however doesn't need to stay like this and can be "broken" again and reconfigured. If there are step by step instructions
that you could provide to do this I'd really appreciate.
Kind Regards -
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. -
Safari Crash - Problem with doodle (planer) app - doodle web links cause safari to crash with a very strange message "Error - Please make sure Safari is not used in Private Modus" (translated from german) No Privat Modus buttom in ios 7 safari settings! Works fine with an older Safari Version. Web link, call doodle app. You could see the website in the backround working but safari crashes after clicking on the error window. Any suggestions?
Turn off Private Browsing.
Tap "Private" on Safari Screen to disable Private Browsing. When top of screen is white, Private Browsing is off. -
Can I use the "Private browsing" mode on mobile?
Can I use the "Private browsing" mode on mobile?
Firefox for mobile does not yet have a built-in Private Browsing mode. However, you can do private browsing in a separate or temporary profile, by running "fennec -P" in the N900's Terminal app, or by using the [https://addons.mozilla.org/mobile/addon/mobile-profiles/ Mobile Profiles] add-on.
-
Should my team use their private apple id:s or should we create new ones?
We have some problems regarding our apple id:s since we use our private accounts in the company.
Should we create new apple id:s just for the company? Whats the benefits? Problems?
How do we do to manage buying apps, music, use Spotify etc?can I use the same email address for multiple Apple ID's?
My two kids dont need e-mail addresses -
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
SudhirHi 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?
ThxDoes 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 -
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.
-
Can someone tell me when a java program would use private methods? I understand that use of private instance variables is the norm and when extending a class, the use of the public methods is required to access the data. But when would it be necessary to use a private method? Thanks.
Okay, so you create a class. And some other class uses that class.
public class Useful {
public void doSomethingUseful() {
public class User {
// Use a Useful to do something useful
Useful u = new Useful();
u.doSomethingUseful();
}Now, you could put a whole bunch of krap into the single doSomethingUseful method, or you could be smart and break its work down into smaller methods, which each method having it's own responsibility. Those methods would be private, because there's no reason to expose the implementation details of the public method. -
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 advanceYour 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. -
Cyclomatic Complexity Using Regex
/ Cyclomatic Complexity Program /
/ Program does not ignore comments in pattern /
/ Program looks for 1 pattern keywords then moves down a line for next search/
/ java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html / /
/ Using Java Regular Expression Class /
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
class Cyclomatic
// uses the java i/o.*
static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
protected String txtFileName;
protected int count = + 1; // start count at one then no need to add 1 to count!
private static BufferedReader reader; // Uses the java.io.*;
public void Cyclomatic()
try {
// open the file
System.out.println("------------------------------" );
System.out.println("CYCLOMATIC COMPLEXITY PROGRAM " );
System.out.println("------------------------------\n\n" );
System.out.println("Enter file name to be read: " );
// Create object to read textfile from keyboard
txtFileName = new String(keyboard.readLine());
System.out.println("\n \n");
// the buffered reader object
reader = new BufferedReader(new FileReader(txtFileName));
// Create a pattern object and split the key words using pipes |||
Pattern pattern = Pattern.compile("if|for|while|case|switch",Pattern.MULTILINE);
Matcher m = pattern.matcher(txtFileName);
boolean b = m.matches(); // return true if match found !
String line = null;
while((line = reader.readLine()) !=null)
m.reset(line);
if(m.find())
count = count +1;
System.out.println("KeyWord " + " found " + " start of line: " + m.start() + " ends at line: " m.end() " Keyword count = "+ count);
reader.close(); // close buffered reader!
if(count >10)
System.out.println("\n \nThis program according to McCabe has a COMPLEXITY OF: " + count +" \n");
else
System.out.println("\n \n This program is NOT COMPLEX \n \n");
catch(IOException e)
System.out.println("Error : " + e.getMessage());
// Run the thing!
public static void main(String[]args)
// Create object Complex
Cyclomatic Complex = new Cyclomatic();
Complex.Cyclomatic();
Does anyone have ideas as how to improve this program so that it can
ignore keywords inside comments, it finds the first keyword on a line
then jumps down to the next line to search. I know how to implement
this program using the Stream Tockenizer Class using the slashStar
comments, just interested in this alternative that I thought of. It works fine
when givin the following test file. Just want to iorn the few problems out.
Test File:
// SAVE AS A TEXT FILE AND OPEN WITH PROGRAM //
// Cyclomatic Complxity for this file is 17 //
1. if
2. if
3. while
4. for
5. if
6. case
7. case
8. if
9. switch
10. for
11. if
12. while
13. if
14. if
no
dont
count
this
15. if
16. for
Gives Correct CC for this layout.Please use [code] tags when posting source code.
End-of-line comments are easy to handle, but the multiline varieties complicate the task quite a bit. They can span multiple lines, but they don't have to, and keywords can occur after the end of a multiline comment. Since you're reading the file line-by-line, you need to use a flag to handle comments that actually span multiple lines. For the rest, you've got capturing groups and the find(int) method: // Pattern for keywords and the start of comments
Pattern p1 = Pattern.compile("(/\\*)|(//)|(if|for|while|case|switch)");
Matcher m1 = p1.matcher("");
// Pattern for the end of multiline comments
Pattern p2 = Pattern.compile("\\*/");
Matcher m2 = p2.matcher("");
boolean inComment = false;
int lineNum = 0;
String line = null;
while ((line = reader.readLine()) != null)
lineNum++;
int startAt = 0;
if (inComment)
// In multiline comment; see if it ends in this line
if (m2.reset(line).find())
inComment = false;
startAt = m2.end();
else
continue;
m1.reset(line);
while (m1.find(startAt))
if (m1.start(1) != -1)
// Start of multiline comment
if (m2.reset(line).find(m1.end()))
// If it ends in this line, we'll keep looking for keywords
startAt = m2.end();
else
// ...otherwise, just set the flag
inComment = true;
break;
else if (m1.start(2) != -1)
// End-of-line comment
break;
else
// It's a keyword
count++;
// If you aren't using Java 5, go back to the old way
System.out.printf("Keyword found in line %2d at position %2d; Keyword count = %2d\n",
lineNum, m1.start(), count);
// We only care about the first one
break;
}Here's the test data I used:1. if
2. if
3. while
4. don't count this // switch
5. for
6. if
7. don't count this /* case
8. for */ ...or this
9. case
10. /* yes count this */ case
11. if
12. switch
13. for
14. if
15. while
16. if
17. if
18. no
19. dont
20. count
21. this
22. if
23. for
Maybe you are looking for
-
Next Slide Problem with Flash In PowerPoint
When I embed a Flash file into a PPT presentation and play Slide Show, my page down (Slide Show advance) key doesn't work once the animation is underway. If I mouse-click the outside borders, it advances properly. Any suggestions on preventing this?
-
HT1923 The program can't start because MSVCR80.dll is missing.
Is there a fix for this message which suddenly appeared after I installed the latest update to Itunes? The program can't start because MSVCR80.dll is missing from your computer. Try reinstalling the program to fix this problem. Then I get Itunes w
-
Outlook 2011 under mountain lion
I have problem with oulook 2011 under mountain lion when I close Outlook and reopen I lose all preferences I set. For example reading pane under instead left, or download images for email ( i set yes and return to never) etc. All my preferences set b
-
"E_ACT_TOO_MANY_ACTIVATIONS or Adobe Activation Request Error 2004," to have the activation count reset.
-
Getting the exception : Exception while getting default policy provider
Using WLST, I shutdown a server, HomePageServer_1 which is part of a cluster, HomePageCluster, successfully. But I am unable to re-start it wither using WLST or admin console. I am getting the following error as per managed server log : +The dynamic