Constraints From another schema

Hi Guys,
I have a table referral_contacts which has a column customer_id.This col is coming from a synonym whose base table is in another schema.
So the current requirement is to establish the referential constratint from that table .I think there is no way to add constraint from a synonym whose base table is in another schema.Is there any method to achieve this without crating the same table .
Any suggestions,coments are highly appreciated.
Thanks,
Prafulla

Hi Prafulla
It will be very tough for maintenance in long term if you create cross-reference constraints across schemas. That won't be a good design unless the same application owns both schemas. If each schema is used by different application and that only the second schema is populated with data realtime which is needed by the other application then you can create a new table and refresh it from the other schema in real time as well. You can check Materialized views (fast refresh, incremental refresh, using rowid, etc) for this purpose or you can also look at various other options (using trigger on the second schema to populate the new table in your schema and keep this in sync with that).
Just for your information, Materialized views is a feature of EE. Tell us more about your environment

Similar Messages

  • Adding named constraints from another schema using stored procedures

    I need some help. I am trying to create a constraint like Primary key on a table in schema say 'a' from schema 'b'. in Oracle 10g. Schema b has all permissions of create, alter table, create index and other permissions required.
    I can create this constraint from schema b using SQL command 'alter table add constraint...' but not from inside a procedure. I am using 'Execute Immediate' statement to alter table to add constraint. While trying from a procdure, it throws the error as 'insufficeint previleges'.
    Kindly advise.

    it is due to roles.
    if schema b has for example role DBA it is not sufficient. You should
    GRANT ALTER ANY TABLE TO B;maybe also CREATE ANY INDEX. not sure...
    regards
    Laurent

  • Possibility of Coping constraints from another schema

    Hi,
    If i drop all constraints of a table in TEST; then is it possible to create constraints on that table from same(with same name and structure) table in PRODUCTION.
    Thanks,
    Vidya

    real quick, may be of help
    SQL> ed
    Wrote file afiedt.buf
      1   SELECT 'alter table  '||f.TABLE_NAME||' add ( constraint '|| FOREIGN.constraint_name
      2          ||'  FOREIGN KEY ('||f.COLUMN_NAME ||')  REFERENCES '|| p.TABLE_NAME||'( '||p.COLUMN_NAME||
      3   FROM user_constraints PRIMARY, user_constraints FOREIGN,user_cons_columns  p, user_cons_column
      4   WHERE PRIMARY.constraint_type = 'P'
      5      AND FOREIGN.constraint_type = 'R'
      6      AND PRIMARY.owner = FOREIGN.r_owner
      7      AND PRIMARY.constraint_name = FOREIGN.r_constraint_name
      8   AND PRIMARY.table_name = p.table_name
      9       AND PRIMARY.constraint_name = p.constraint_name
    10* AND FOREIGN.constraint_name = f.constraint_name
    11  /
    'ALTERTABLE'||F.TABLE_NAME||'ADD(CONSTRAINT'||FOREIGN.CONSTRAINT_NAME||'FOREIGNKEY('||F.COLUMN_NAME|
    alter table  EMP add ( constraint FK_DEPTNO  FOREIGN KEY (DNO)  REFERENCES DEPT( DEPTNO));

  • How can i access all the objects of one schema from another schema

    Dear All,
    How can i access all the objects(Tables,Views,Triggers,Procedures,Functions,Packages etc..) and do the modifications of one schema from another schema (Without using synonyms concept).
    Thanks in advance,
    Mahi

    First of all, synonyms only help you easy reference the object. It doesn't have any implication of object privilege.
    As long as you have proper privilege on target object. You can access it with or without synonyms.
    Assuming you have proper privilege of objects, you can use following command to assume schema owner.
    ALTER SESSION SET CURRENT_SCHEMA = Schema_owner

  • How to extract all keys (PK, FK) and constraints from the schema?

    hi,
    How to extract all keys (PK, FK) and constraints from the schema?Thanks!

    I have no idea about any tool which only extract the DDL of constraints.
    In oracle 9i or above you can use DBMS_METADATA to extract DDL of a table which also shows contraints defination.
    You can take the tables export without data and use databee tool to extract the DDL.
    www.databee.com

  • Cant view objects from another schemas

    Hi everybody!
    I have a 10.1.2 Jdeveloper and a 9.2.4 Oracle database.
    I successfully created a database connection.
    With provided login I can access to tables from another schemas in SQL Worksheet, but I cant see any objects from those schemas in the connection tree.
    What's wrong?

    The Schemas are being filtered so that you only automatically see the schema for the connection that you logged on with. To change the schemas that are visible you need to :
    1) Select the connection name in the Navigator (you should see that it has a filter icon overlaid showing that it is being filtered)
    2) Invoke the context menu and select 'Apply filters'
    3) Shuttle over the other Schemas you wish to see and press OK
    Regards,
    Lisa Sherriff
    JDev QA

  • Selection from Another schema by default without schema name qualifier.

    Hi
    Oracle10g release 2, LinuxOS
    i want my schema (User_1) to always select,insert, update, delete the objects from another schema (User_2) without passing full schema qualifier every time whenever i don't pass any schema name explicitly.
    i.e. if i pass the following guerry
    select * from table_a;
    the table of user User_2.table_a (User_2.table_a) will be queried by default instead of table (User_1.table_a)
    and the same implementation is also required in Functions , procedures, sequences etc.
    Wishes

    Three relatively easy options
    1) Create private synonyms in User_1's schema for each object in User_2's schema, i.e.
    CREATE SYNONYM table_a
       FOR user_2.table_a2) Create public synonyms for each object in User_2's schema. This will make it possible for all users to query user_2's objects without specifying the schema name
    CREATE PUBLIC SYNONYM table_a
       FOR user_2.table_a3) Change the current schema for the session (potentially in a login trigger)
    ALTER SESSION SET current_schema = USER_2There are other options that are a bit more complicated like using enterprise users with shared schemas. But most people are perfectly happy with one of these three.
    Justin

  • Selecting from another schema

    If I want to select table from another schema, I have to type
    select * from [username].table_name.
    What can I do inorder not to write shema name all the time.
    for instance:
    instead of writing
    select * from [username].table_name.
    select * from table_name.

    create synonym for the object in other schema:
    create synonym <syn-name> for schema.tablename;
    then use syn-name in place of schema.tablename in ur query
    like
    select * from syn-name;

  • SQL Report From Another  Schema

    Is there anyway to select a table from another schema?I have a default schema for my application but i want each user to use their own schema.
    I'm looking for something like #OWNER#.table_name but replacing #OWNER# with the name of another schema in the workspace.
    Kind Regards,
    BgUrsea
    APEX 4.0 10g XE

    Hello BgUrsea,
    you could achieve this by granting the needed privileges (e.g. select, insert, update, delete) on each table in the #OWNER#-schema to your applications parsing schema.
    If you can't use a direct mapping (e.g., you can't assign the schema name of a user as usernames for his application user), you probably need a mapping table in your parsing schema. Define an application item (e.g. "F_OWNER") and create a application computation that executes "On New Instance" and does something like
    SELECT schema
      FROM mapping_table
    WHERE owner=v('APP_USER');If you aren't sure you always have a mapping, you might think about an application process that not only computes the value but also handles the action to be performed in case there is no mapping for a user.
    But I suppose it could be easier to have a copy of you application for each user and assign the appropriate schema to each copy. That way, you don't need the mapping, you don't need to care about always using the #OWNER# when developing your application, and of course, no user can (not even accidently) access another users (or your default) schema.
    -Udo

  • How to defer constraint of one schema from another schema

    Hi All,
    I am having a requirement of migrating data from one schema(SCHEMA_A) to another schema(SCHEMA_B). So I tried to implement the same using PL/SQL.
    Because of foreign key contraint while migrating child table, Oracle throws an error message like parent key not available.
    So I tried to set the all contraints to deferred and after completion of migration i planned to set all the contraints to immediate.
    But Here I am executing the procedure from schema(SCHEMA_C) which has rights to access SCHEMA_A and SCHEMA_B.
    How could I able to defer all the constraint in SCHEMA_B from SCHEMA_C?
    Thanks in Advance,
    Antany.

    Yes,
    You could run something like this, for foreign keys:
    BEGIN
      FOR cur_rec IN (SELECT table_name, constraint_name FROM DBA_CONSTRAINTS WHERE OWNER = <owner> AND CONSTRAINT_TYPE = 'R' )
        LOOP
          EXECUTE IMMEDIATE 'ALTER TABLE <owner>.' || cur_rec.table_name || ' DISABLE CONSTRAINT ' || cur_rec.constraint_name;
        END LOOP;
    END;
    /

  • Is it possible to have FK tbl constraint to another schema?

    Has anybody created successfully in OWB FK table constraints that point to a table in a different schema in the same instance?
    Here is what I tried ...
    Under table properties I created FK constraints that point to a table in another schema in the same instance. I used the drop-down list with locations under "Referenced Application" and then made column selections from drop-down lists below under "Local Columns" and "Referenced Columns". No problems with validation.
    In the source schema I granted select and reference privileges. The generated code can be executed manually with no errors. However, I can't deploy a table like this. I get "VLD-0917: An unknown error occurred while generating ..."
    Per tech support you can't have constraint references across nodes. However, I think this is somewhat different since it is all in the same instance.
    Does anybody have any experience with this?
    Thanks in advance,
    Julian

    Appears that after applying OWB patch 9.2.0.3 my problem went away. I created new schemas (design, runtime, target) after applying this patch also. Not sure what exactly fixed the problem in the end.
    Thanks,
    Julian

  • Create stored procedure with table from another schema throws PLS-00201

    Oracle 10g. I'm new to procedures, so maybe I'm missing something obvious.
    Schema owner ABC has table T2001_WRITEOFF. The SYSDBAs granted SIUD to Some_Update_Role, and granted that role to developer user IJK. User IJK then created a private synonym T2001_WRITEOFF for ABC.T2001_WRITEOFF. This worked with normal SQL DML commands. 
    When I try to create a simple procedure as follows, it throws PLS-00201 identifier 'T2001_WRITEOFF' must be declared, and points to the 2nd line.
    create or replace procedure woof1(
      fooname in T2001_WRITEOFF.territory%TYPE,  <=== error points here
      bardesc IN T2001_WRITEOFF.ind_batch_submit%TYPE) IS
    BEGIN
       INSERT into T2001_WRITEOFF
       VALUES ( fooname, bardesc);
    END woof1;
    What am I doing wrong?
    Thanks
    JimR

    Hi,
    The reason I've heard has to do with knowing when a procedure becomes invalid due to privileges being revoked.  Any time a grant to a role is revoked, you would have to check all procedures that depended on that role to know if they were still valid.  Even worse, since roles can be granted to other roles, every time a role is revoked from another role, you would have to check all procedures that depended on anything to see if they were still valid.
    Oracle 11 behaves the same as earlier versions in this regard, and I don't expect this to change.
    This whole thread applies only to AUTHID DEFINER stored procedures (which is the default).  If you can make the procedure AUTHID CURRENT_USER, then you can run it with privileges granted through roles.  Usually, however, you really want AUTHID DEFINER, and granting the necessary privileges directly to the procedure owner (or to PUBLIC)  isn't too hard.

  • Renaming View from another schema

    Hi,
    I've 2 schemas  namely  department  ,  hr
    Now department schema is having one table EMP . And a view is created on that table with the name R_EMP
    Schema Name :  department
    Table Name  :  EMP
    View Name   :  R_EMP
    GRANT SELECT ON R_EMP  TO  HR ; 
    In HR schema a synonym has been created on view R_EMP with the name R_EMP .
    CREATE OR REPLACE SYNONYM hr.R_EMP for department.R_EMP
    Schema Name :  hr
    Synonym Name:  R_EMP
    Now I want to rename the view name R_EMP  to V_EMP  from  HR schema only
    So, I tried the folloiwng syntax in HR schema (All the operations should be done from this schema only )
    [code]
    RENAME department.R_EMP to department.V_EMP ;
    Error:
    ORA-01765: specifying table's owner name is not allowed
    [/code]
    How to change the syntax to make the statement work from HR schema .
    Thank You .

    Smile,
    The questions is pretty much answered now. You might want to have a look at this as well.
    How to rename a table in another user's schema
    You can alter the session to set your current schema to the name of the schema where you want to rename the view and then do a direct rename.
    Thanks,
    Ishan

  • To kill session in one schema from another schema

    Hi Team,
    I got a problem like a table from one of my schema has been locked. I am getting 'ORA-00054: resource busy and acquire with NOWAIT specified' error when trying to delete rows from that table or even when trying to truncate that table.
    Let the table be 'T1' present in schema 'VIEW'
    I tried to kill the session which is active for that schema by below query
    select sid,serial#,status from v$session where username='VIEW' and STATUS = 'ACTIVE';
    alter system kill session '681,2586';
    But i couldn't do the above as i don't have DBA privilege for that. But i have DBA privilege for another schema let it be 'ADMIN'
    Now how can i kill the session in schema 'VIEW' from schema 'ADMIN'
    can any one get me solution.
    Thanks in Advance
    11081985

    I got a problem like a table from one of my schema has been locked. I am getting 'ORA-00054: resource busy and acquire with NOWAIT specified' error when trying to delete rows from that table or even when trying to truncate that table.
    Before you do anything why don't you actually find out WHY that table has been locked.
    You generally should NOT be killing sessions without knowing what is causing the problem to begin with.
    Then you also need to determine if you should use KILL SESSION or instead use DISCONNECT SESSION and well as whether the use of IMMEDIATE is appropriate.
    Each of those choices acts differently. Many people use KILL when they should really use DISCONNECT.
    See DISCONNECT SESSION Clause and KILL SESSION Clause in the ALTER SESSION chapter of the SQL Language doc
    http://docs.oracle.com/cd/E11882_01/server.112/e17118/statements_2014.htm#i2282145

  • Help in writing  query few schema objects  from another schema.

    Hi Gurus,
    Could some one help in writing an sql which will give list of all the object of a schema "genp" visible in another schema "genp_v" and "gen_con" there is an dblink and few grants on those schemas .
    i dont have the password of any of those users i have connected as sys and i can not change the password of any of those users..
    Any help on this is highly apprciated.
    Thanks in advance .

    could you please update me for all the objects apart from just the tables .
    thank you so much .. it was just out of my head at that moment .
    cheers

Maybe you are looking for

  • JAI Javadoc + Netbeans

    Hi! Does anybody know which packages to install and how to install JAI (java advanced imaging) documentation on Netbeans? The idea is to have the information about the methods while programming on Netbeans, as it happens with standard JAVA. Thanks

  • To change language

    Hello, how can I change the language in the application server to a Russian?

  • "Can't contact Spell Checker".... in ANY program?

    I've been getting the message "Can't or Couldn't contact Spell Checker" in both Neo Office and Text Edit, or any non-browser program that uses word processing. It used to happen some in Safari, but the latest version seems to have fixed the issue w/t

  • HT5129 How can I get my MobileMe albums transferred over to iPhoto?  It keeps freezing on me!

    When I launch iPhoto, it gives the standard message that MobileMe has been discontinued and that it will transfer albums to a folder in iPhoto.  But then a progress meter comes up and doesn't move.  It just freezes.   Any ideas?

  • FIOS 150/150 but only showing 95/95 on Verizon Speed Test

    Some context - have been on the 150 plan for about 6 months since dumping TV and Phone Service. I originally had the Quantum gateway router but was dissatisfied with the wireless coverage.Purchased a Netgear R7000 about 5 months ago and used it as an