Deliberate use of dblink between schemas of a same database

As I've read in a post from Igor: "The generated code is not using the DB links if the source and target are in the same DB"
This is an interesting feature but is there a way to turn it off ?
As a matter of fact, a database link provides powerful security functionality as target user/schema can behave like source user/schema through the link.
How do I manage to simulate the same now that mapping in TARGET expand with SOURCE.* prefix ?
Shall I have to create a role and grant manually access to every new object in schema SOURCE to user TARGET ?

See my answer in the "Want to get rid of DBLINKS between locations" thread.
Regards:
Igor

Similar Messages

  • DBlink between two schema on the same database.

    Hello,
    I am facing a troublesome situation here regarding a database link. Usually I create my db links between two databases hosted on two different servers but in this current situation, am in short of machines. The database informations are contained in two different schema that were suppoded to be imported on two different databases(servers). As only one machine is available,I would like to know given the situation, whether I can create two schemas on the same database and link both schema using a database link. Is it possible? If yes, how do I achieve that?
    Thanks in advance.

    adomi wrote:
    Hello,
    I am facing a troublesome situation here regarding a database link. Usually I create my db links between two databases hosted on two different servers but in this current situation, am in short of machines. The database informations are contained in two different schema that were suppoded to be imported on two different databases(servers). As only one machine is available,I would like to know given the situation, whether I can create two schemas on the same database and link both schema using a database link. Is it possible? If yes, how do I achieve that?
    Thanks in advance.Cann't understand you. If you transfer data between two databases, then use database link. If you use only one database, then you don't need to use database link. Please elaborate more

  • Creating a database link to another schema in the same database

    Hello,
    I'm trying to create a database link to another schema in the same database. It was created without errors, but when I try to use it I receive "ORA-12154: TNS:could not resolve the connect identifier specified" message...
    I'm trying to do it because on my production enviroment the databases are separated, so there I can use database links without problem, but in my development environment it's all in one database separated by schemas...
    So I'm trying to simulate the same system to not need to rewrite the query every time I move from development to production environment.
    Any ideas?
    Thanks

    Hi,
    Yes, you can create a database link to your own database. I've done it before for exactly the same reason you want to.
    (By the way, I think it's a good reason. What are the alternatives?
    Having different versions of code for Development and Production? Absolutely not! Terrible idea!
    Using synonyms or substitution variables that are set differently in the different databases? That might be more efficient than a database link, but efficiency probably isn't such a big issue in Development.
    [Conditional compilation|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/fundamentals.htm#sthref250]? This might be good; it has all the efficienty of the above options, with more clarity.)
    Assuming you do want to stick with a database link, not all errors are caught when you create the link.
    Is the Development database in the tnsnames.ora file of the Development server? Do you have other database links, either in the Development server or pointing to it, that work? What is different about the ones that work, and the one that doesn't?
    Edited by: Frank Kulash on Oct 14, 2009 1:58 PM
    The more I think about this, the more I agree with the earlier respondent: synonymns are a good solution for this.
    To that suggestion you replied:
    On this way I might use "select * from SCHEMA.table" instead of "select * from table@SCHEMA"... I looking for an option to use the second way...Actually, the suggestion was that you say:
    select  *
    from    SCHEMA_table_ptr;where schema_table_ptr is a synonym.
    In Development, that synonym is defined as schema.table.
    In Production, that synonym is defined as table@SCHEMA
    Why are you "looking for an option to use the second way"?
    If you think that people reading the code should realize that the query is being done via a database link (at least in Production), then add a comment.

  • How to check relation between two tables in same database

    How to check relation between two tables in same database using Oracle SQL developer. Version 2.1.1.64

    Hi,
    Try this,
    SELECT   cons.owner AS child_owner, cons.table_name AS child_table,
             cons.constraint_name constaint_name,
             cons.constraint_type constraint_type, col.owner parent_owner,
             col.table_name parent_table, col.column_name column_name
        FROM dba_cons_columns col, dba_constraints cons
       WHERE cons.r_owner = col.owner
         AND cons.r_constraint_name = col.constraint_name
         AND col.owner = 'MY_USER'
    ORDER BY child_table;Thanks,
    Shankar

  • Two ifs schemas on the same database?

    Can I use two different ifs schemas on the same oracle DB for two different IFS instances on two different machines? I don't want to run two databases due to memory issues, but I wanted to run two different ifs schemas (one for development/testing, and one for production). Are there any issues associated with this?

    I am not aware of any iFS-specific issues if you are running the database on a separate machine from your middle-tier iFS boxes.
    But you will have the standard problems of having one database for development and production (e.g. if you need to bring down the development database for any reason, you impact the production database, since they're the same).
    The only problem I can think of related to iFS is that you will be sharing one Context queue, so that if you have any documents loading in from your development environment which cause problems in the queue, your production iFS will suffer.

  • Oracle Streams setup for multiple schemas in a same database

    We are on 11.1.0.7 and will be using Oracle 11g Streams that will replicate the data real-time for two schemas between the source and target set of schemas with in the same database. We will be doing DDL as well as DML replication.
    I created the following plan and want your inputs. After implementing this, I created a table in SCOTT but it's get replicated to RPT_SCOTT later I tried inserting a row in the table created under SCOTT but that too didn't get replicated to RPT_SCOTT.
    Here are the steps that I used to set up my STREAMS -
    Database Instance:     TESTDB
    Schemas:
         Source:          SCOTT
                   HR
         Target:          RPT_SCOTT
                   RPT_HR
    Configuring Streams:
    1.     Database is in Archive log mode
    2.     Set up the Streams administrator.
    create user STRMADMIN identified by STRMADMIN default tablespace USERS temporary tablespace temp;
    grant resource, dba, AQ_ADMINISTRATOR_ROLE to STRMADMIN;
    BEGIN
    DBMS_STREAMS_AUTH.GRANT_ADMIN_PRIVILEGE(
    grantee => 'STRMADMIN',
    grant_privileges => TRUE);
    END;
    3.     Set up Streams queues
    CONNECT STRMADMIN/****
    BEGIN
    DBMS_STREAMS_ADM.SET_UP_QUEUE(
    queue_name => 'STREAMS_QUEUE',
    queue_table => 'STREAMS_QUETAB',
    queue_user => 'STRMADMIN');
    END;
    4.     Add the Apply rule
    BEGIN
    DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
    schema_name      => 'RPT_SCOTT',
    streams_type     => 'APPLY',
    streams_name     => 'APPLY_CC_STREAM',
    queue_name          => 'STRMADMIN.STREAMS_QUEUE',
    include_dml     => true,
    include_ddl     => true,
    inclusion_rule     => true,
    source_database     => 'TESTDB');
    END;
    BEGIN
    DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
    schema_name      => 'RPT_HR',
    streams_type     => 'APPLY',
    streams_name     => 'APPLY_AB_STREAM',
    queue_name          => 'STRMADMIN.STREAMS_QUEUE',
    include_dml     => true,
    include_ddl     => true,
    inclusion_rule     => true,
    source_database     => 'TESTDB');
    END;
    BEGIN
    DBMS_APPLY_ADM.ALTER_APPLY(
    apply_name     => 'APPLY_CC_STREAM',
    apply_user     => 'STRMADMIN');
    END;
    BEGIN
    DBMS_APPLY_ADM.ALTER_APPLY(
    apply_name     => 'APPLY_AB_STREAM',
    apply_user     => 'STRMADMIN');
    END;
    5.     Add the Capture Rule
    CONNECT STRMADMIN/*****
    BEGIN
    DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
    schema_name     => 'SCOTT',
    streams_type     => 'CAPTURE',
    streams_name     => 'CAPTURE_CC_STREAM',
    queue_name          => 'STRMADMIN.STREAMS_QUEUE',
    include_dml     => true,
    include_ddl     => true,
    inclusion_rule     => true,
    source_database     => 'TESTDB');
    END;
    BEGIN
    DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
    schema_name     => 'HR',
    streams_type     => 'CAPTURE',
    streams_name     => 'CAPTURE_AB_STREAM',
    queue_name          => 'STRMADMIN.STREAMS_QUEUE',
    include_dml     => true,
    include_ddl     => true,
    inclusion_rule     => true,
    source_database     => 'TESTDB');
    END;
    6.     Set the instantiation system change number (SCN)
    CONNECT STRMADMIN/******
    DECLARE
    source_scn NUMBER;
    BEGIN
    source_scn := DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER();
    DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN (
    source_schema_name => 'SCOTT',
    source_database_name => 'TESTDB',
    instantiation_scn => source_scn);
    END;
    7.     Start the Apply
    CONNECT STRMADMIN/******
    BEGIN
    DBMS_APPLY_ADM.START_APPLY('APPLY_CC_STREAM');
    END;
    BEGIN
    DBMS_APPLY_ADM.START_APPLY('APPLY_AB_STREAM');
    END;
    8.     Start the Capture
    CONNECT STRMADMIN/******
    BEGIN
    DBMS_CAPTURE_ADM.START_CAPTURE('CAPTURE_CC_STREAM');
    END;
    BEGIN
    DBMS_CAPTURE_ADM.START_CAPTURE('CAPTURE_AB_STREAM');
    END;
    Waiting for your inputs!

    If I understand from your code, you want to do this on the same DB :
    SCOTT --> RPT_SCOTT
    HR  --> RPT_HRSo there is a schema transformation, where is it coded ?
    General info : http://download.oracle.com/docs/cd/B28359_01/server.111/b28321/strms_transform.htm
    More specific on schema rename : http://download.oracle.com/docs/cd/B28359_01/server.111/b28321/strms_mtransform.htm#CHDGDHDE
    Next : where are the initialisation of both capture schema ?
    Missing :
    execute DBMS_CAPTURE_ADM.PREPARE_SCHEMA_INSTANTIATION( schema_name          => 'scott'');
    execute DBMS_CAPTURE_ADM.PREPARE_SCHEMA_INSTANTIATION( schema_name          => 'HR'');This tell Streams from where to capture the SCN.
    Also there is an (WRONG) instantiation of SCOTT for the apply, which tells the apply to consider as valuable candidate all LCR after source_scn,
    but where is the code or RPT_HR. Alas, you put for the APPLY target schema 'SCOTT' while it should have been 'RPT_SCOTT'.
    the fact that is correct or false depends where you put the schema transformation. If you put the transformation at apply time then use the SOURCE schema name (SCOTT, HR) for the LCR will contains their name. If you put the transformation at capture time, then put target schema name for the LCR will contain their name (RPT_HR,RPT_SCOTT).
    Let's say you put the schema transformation at capture time then
    Missing:
    DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN (
    source_schema_name => 'RPT_HR',
    source_database_name => 'TESTDB',
    instantiation_scn => source_scn);If you attache the transformation on the apply process then the code is :
    DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN (
    source_schema_name => 'HR',
    source_database_name => 'TESTDB',
    instantiation_scn => source_scn);And this is useless:
    -- useless code
    BEGIN
    DBMS_APPLY_ADM.ALTER_APPLY(
    apply_name => 'APPLY_CC_STREAM',
    apply_user => 'STRMADMIN');
    END;
    BEGIN
    DBMS_APPLY_ADM.ALTER_APPLY(
    apply_name => 'APPLY_AB_STREAM',
    apply_user => 'STRMADMIN');
    END;
    /Last : You are using the same queue for 2 separated capture/apply transformation.
    Do yourself a favor and give each couple capture/tranform/apply its own queue.

  • Dblink between different version of oracle databases

    Hi Oracle Database Gurus
    Is it possible to create a database link between 10.x and 11.x oracle database.
    Could somebody pinpoint a passage of oracle documentation connected with that topic.
    Regards
    Zibi

    zibi wrote:
    OK thanks, but is there a documentation where we can find some constraints ???
    ZibiRemember that there is nothing "magic" or special about dblinks. When using the link, the database in which the link is defined (source) is just another client to the target of the link. It uses all of the same tns pieces, and the constraints between versions would be the same as for any other client / database connection. So all you need to reference are the standard docs on what client versions are compatible with what db versions. Nothing special for the dblink.

  • Any problem with dblinks between 8.1.7 and 10gR2?

    Hi,
    Just want to know if any of you have encountered problem using a dblink between an Oracle database 8.1.7 and a brand new 10.2?
    I guess simple query from the 8i db to 10gR2 data would be OK...or not!?
    But what for queries with joins???
    Many Thanks in advance for your help,
    Sebastien

    Could any of you 'copy & paste' the Metalink Note:207303.1 here on the OTN forum?

  • Different schema on same database

    i have 2 schemas in the same database, i create a table in one schema and can access the same table from the other schema without grant option. For eg, i create one table 'emp' in one schema 'schema1' like:
    create table emp(no number);
    Now, from the other schema, schema2, i can access this table data using the following select statement :
    select * from schema1.emp;
    without first giving the grant on the table from 'schema1' like this:
    grant select on emp to schema2.
    Please help in solving my doubt as i need it resolved urgently.

    Have you (perhaps mistakenly) granted a user the SELECT ANY TABLE privilege?
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Cloning Schema within same database in DG environment

    Hi guys,
    I have a Production database with Data Guard configured (2 physical standbys, one same DC, 2nd other DC). I need to clone a schema (size approx. 380GB) within the same database, ofcourse creating cloned schema with a new name.
    Example:
    ======
    Primary DB: wflprd
    Standby 1: wflprddr1
    Standby 2: wflprddr2
    Source Schema: PegaRules - Size 380 GB
    Desitnation Schema: NewSchema within same database
    what are possible options available? expdp/impdp?
    regards,
    Anjum

    I believe my question is not understood correctly or may be I put the question incorrectly.
    I understand expdp/impdp or exp/imp works but is this the only solution in case of large schema sizes and data guard in place.
    log_archive_dest_1 = LOCATION=/u03/orarch/wflprd, valid_for=(ONLINE_LOGFILE,ALL_ROLES)
    log_archive_dest_2 string service="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=baswflprddatz02)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=wflprddr1_XPT)(INSTANCE_NAME=wflprddr1)(SERVER=dedicated)))", ARCH SYNC NO AFFIRM delay=0 OPTIONAL max_failure=0 max_connections=1 reopen=300 db_unique_name="wflprddr1" register net_timeout=180 valid_for=(online_logfile,primary_role)
    log_archive_dest_3 string service="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=actwfldredatz01)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=wflprddr2_XPT)(INSTANCE_NAME=wflprddr2)(SERVER=dedicated)))", ARCH SYNC NO AFFIRM delay=1440 OPTIONAL max_failure=0 max_connections=1 reopen=300 db_unique_name="wflprddr2" register net_timeout=180 valid_for=(online_logfile,primary_role)
    Objective: We have one big schema containing data of three different customers. We are segregating that big schema into different schemas, one for each customer. So, once schema is cloned within same database, irrelavent data is cleaned.
    regards,
    Anjum

  • Want to get rid of DBLINKS between locations

    Hi
    We got one challenge to work out, Between location in OWB it creates CONNECTORS. These connectors are nothing but DBLink objects in the database. Basically client does not want this connector to be used in generated code . So we need to suppress this connector somehow. The client feeling that,if it uses dblink it is performance hitch, and moreover we have source and target in the same database
    So Can anybody tell me a way to suppress these connectors.
    I appreciate your help on this regard
    Balaji

    Xavier,
    This might not possible automatically as it could represent a security breach. One way of doing this is to create an 'on create' DDL trigger on your schema that enqueues a job in the jobs subsystem (you cannot call the grant command directly from the trigger). The job is then executed as soon as possible and explicitly grants the privilege to the user. I have not tried this and don't know if it works, but it might be worth a try.
    -- To create a 'on create' trigger in your schema, the code is something like (in this example, the schema is the OE schema):
    create or replace trigger on_create
    after create
    on oe.schema
    begin
    insert into control_table values (ora_dict_obj_name,'username');
    -- ora_dict_obj_name is the name of the created object - this info is available for free from the database;
    -- activate the job:
    dbms_scheduler.enable('ON_CREATE_GRANT');
    end;
    -- to create the job schedule:
    begin
    dbms_scheduler.create_schedule(
    schedule_name => 'GRANT_SELECT_SCH',
    repeat_interval => 'FREQ=MINUTELY' -- here you can put different frequencies...
    end;
    -- to create the job:
    begin
    dbms_scheduler.create_job(
    job_name => 'ON_CREATE_GRANT',
    schedule_name => 'GRANT_SELECT_SCH',
    job_type => 'stored_procedure',
    job_action => 'grant_select',
    enabled => false
    end;
    -- the procedure would have to be a dynamic SQL, something like:
    create or replace procedure grant_select is
    ex_statement varchar2(2000);
    begin
    -- check if there are rows in the control table
    -- if there are no rows exit, if there are rows,
    -- for each row in a cursor, select the object name and the user name to create the statement string and run it, something like this:
    ex_statement := 'grant select on '||object_name||' to '||user_name;
    execute immediate ex_statement;
    -- at the end - cleanup by deleting the processed rows in the control table and disable the job:
    dbms_scheduler.disable('ON_CREATE_GRANT');
    end grant_select;
    As mentioned, I did not test this solution and most of it is just pseudocode, but it might be a good starting point.
    Regards:
    Igor

  • Using sequence in diff schema (OWB 10g R1)

    I am trying to use a sequence belonging to instance A schema 1...in a mapping whose objects (source, target tables) are in instance B schema 2.
    How do i do this in OWB ?
    I imported the sequence from the schema 1 into the mapping using a DBLINK...betn the 2 schemas. i did not deploy the sequence using deployment mgr into target schema. I executed the mapping after deploying other objects...and I am getting an error: sequence doesn't exist.
    i even stated the schema and the particular db link name in the configuration of the particular mapping before executing.
    i am trying to run the following SQL statement (it inserts records appropriately in TOAD) using OWB....but am unable to generate a mapping in OWB with the @CDW.WORLD. That could be the potential problem.
    INSERT INTO TEST_TARGET.TEST_TAB_VW (ATTRIBUTE, VALUE,PROFIT_CENTER,PC_ID)
    VALUES ('TESTING','VAL',300098210,[email protected])
    Your guidance will be invaluable.
    Thank you all.
    Message was edited by:
    fire_fighting

    Urghh,
    developing and not being allowed to create a sequence. You have a tough task.
    I can think of two ways to do this. But I can not test it myself, sorry.
    First, create a source module. One in wich you normally only have source tables and views. Let this point to the database/schema where you have the sequence. with a dblink. Import the defenition of your sequence. Use your sequence in a mapping you make in a dwh module. If you generate the mapping, it should be with the dblink information. Just as it would generate the connection for a source table or view.
    If this does not work. The dirty way is to make the sequence in the dwh module and just use it in your mapping. After deployment of your mapping, edit the mapping source. It is just plain pl/sql. Find every occurence of the sequence and replace it with one on the remote server. Perhaps you can make a macro for it.
    There are many good reasons why you don't want to use post-generation-steps. Maintenance, documentation, error-prone etc.
    But it works. :-)
    Hope this helps.
    Maarten Vinkhuyzen

  • How to create dblink between oracle 10G and mysql

    I want to create dblink between oracle 10G and mysql
    I create it in ECC6.0 using DBCO transaction tcode,which database type can choose?Microsoft sql server?Because there have no mysql item.
    I choosed MSS  so that I can test it, but it failed,there is an error that 'ORA-12569:TNS:packet checksun failure'.
    I configured the oracle tnsnames.ora file like this:
         CW.WORLD =
               (DESCRIPTION =
                    (ADDRESS_LIST =
                          (ADDRESS =
                                  (COMMUNITY = SAP,WORLD)
                                  (PROTOCOL = TCP)
                                  (HOST = XX.XX.XX.XX)
                                  (PORT = XXXX)
                   (CONNECT_DATA =
                        (SID = XXX )
                   (HS = ok )
    When I tnsping CW,it will fail,like this " TNS-12569:TNS:packet checksum failure"
    How can I do.

    I want to know if this possible?

  • Query between schemas

    We are migrating our application from SQL Server 2005 to ORacle 9i. We used to have queries that extracted data between different databases in SQL Server, we've encountered problems doing the same in ORacle. What used to be separate Databases in SQL Server appear now as different Schemas in Oracle. Ive read about Database Links and making use of them in our queries but Im not sure if this applies here since we are using the same database, just different schemas.
    I appreciate your help,
    JD

    JD,
    In FROM clause you can specify the schema, for example:
    SELECT *
    FROM s1.t1,
             s2.t2
    WHERE ...Also, you need to grant access accordingly. If the query is executed by user (schema) s1, then s1 must have SELECT privilege to read data in table s2.t2.
    GRANT SELECT ON s2.t2 TO s1Finally, you do a better job if you use roles, not granting privileges direct to users.
    Read about grants and roles.
    Regards,
    Miguel

  • DbLink between 10g and 8i databases

    Hi all
    I have a little problem. I have two different databases in two different versions 10.6 and 8.1.7. Some forms (developer 6.i) use the dblink and i get a crash to desktop when i try to compile. Developer exit with abnormal termination.It is due to tables with the dblink aren´t recognized because if i comment the select where these tables are used the programm compiles perfectly.
    But when I go to SQL plus,for instance, and use a DESC, the tables are recognize in this case. All the synonym are created correctly.
    Any help? Maybe it's due to the different database versions?
    Thanks in advance

    Hi,
    Maybe you should post this problem in a Forms Forum too.
    DbLink between 10g and 8i databases
    Cheers

Maybe you are looking for