Home > Ask the Oracle Experts > (Archive) App Dev: PL/SQL and XML Questions & Answers > Two schemas on a single database
Ask The Oracle Expert: Questions & Answers
EMAIL THIS

Two schemas on a single database

Lewis Cunningham EXPERT RESPONSE FROM: Lewis Cunningham

Pose a Question
Other Oracle Categories
Meet all Oracle Experts
Become an Expert for this site


Oracle tips, scripts, and expert advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 12 July 2005
Suppose I have 2 schemas/users on a single database (s1 and s2) and s1 executes procedure prc1 in s2 which updates the table t1. Also imagine both s1 and s2 have the table t1 (same structure). Which table will be updated?

My vote is for table t1 in schema s2.

I would like to know what are the privileges that control this condition? i.e., what are the privileges to be given for executing the procedure and updating the tables in another schema?


>
EXPERT RESPONSE
A procedure sets its dependancies at compile time, not run time, so once a procedure is compiled, that doesn't change.

There is also an order of dependancy checking. Oracle first looks in the current schema for an object, then any private synonyms and finally any public synonyms.

So, if you compile a procedure and you have a table of name 'x' in your schema, it doesn't matter if anyone else has a table of that name. You procedure will always use the same 'x' table.

If you compile a procedure and you do not have a table named 'x' in your schema, Oracle will look to see if you have any private synonyms named 'x' and finally any public synonyms named 'x.' If it finds one it will always use that schema's 'x' even if you create a table in your schema afterwards.

The safest ways to ensure which schema's table you are using is to either prepend the schema owner to the table name, i.e. s2.t1, or to use "alter session set current_schema = s2;"

To use a table in another schema, you would need at least select permission on that table. To create a procedure using a table in another schema, you would need select granted directly to your user name and not to a role.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
(Archive) App Dev: PL/SQL and XML
Detect if a column is NUMBER or VARCHAR2 in PL/SQL
Loading data into Oracle
Log execution time for a procedure
Hiding objects in a schema
Query for five most recent dates
Connecting with Visual Basic
SQL ANSI standards and compliance
Developing a parser for recognizing HTML tags
Oracle and SOAP
Concatenating XML fragments

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts