Accessing data of one DBCS to another DBCS - oracle

I have two DBCS instance. DB1 and DB2. I want to access data of DB2 instance in DB1.
I dont want to copy the data , I just want to access for reporting purpose.
Can you please help me on the same.

Within DB1, create a db link to DB2:
CREATE PUBLIC DATABASE LINK "DB2"
CONNECT TO "db2user" IDENTIFIED BY "db2userpwd"
USING 'DB2';
Create a tnsnames.ora entry (in the tnsnames.ora of the DB1 machine) for DB2
Then when you want to select the data,
select * from my_db2_table#DB2;
Read more on DB Links in the SQL Reference.create database link
BTW, in the CREATE statement above, the two strings 'DB2' do not have to be the same, but probably should be for consistency. The first (CREATE DATABASE LINK DB2) is the name of the link and is what is referenced in the sample SELECT statement. The second (using 'DB2') is the reference to the tnsnames.ora entry.

Related

Where Can I find the source of this temp file in VB 6.0

I Want to know the sourse of this table. How it is calculated from the table. I am using sql server r2 2008 and I searched for that table, but it is not there. It is formed by manipulating some rows of different tables. Is there any way to find it. I searched the corresponding table in VB 6 also. but it is not there. Is there Any way to find the source table?
Source in local variables is :
"Select * From #70554TempShiz52"
Tables with name starting with # or ## are temporary tables (Quick Overview: Temporary Tables in SQL Server 2005).
The table exists only as long as the connection in which table was created exists. It is accessible only from connection which has created it.
To find the table you should look for an appropriate statement CREATE TABLE #70554TempShiz52 in the code.
The table is exists in tempdb database. An admin can see it there using ssms (only when the connection is still open and table was not dropped). I usually put a breakpoint to achieve desired state. The name of the table looks like #70554TempShiz52__________...some number (to distinguish tables from other users).
I can be useful to use a name starting with ## for debugging because such a table is visible from other connections.

oracle query talend etl

I am a beginner to use talend etl I would make a request to select a database oracle then make a change _ S and insert it into a mysql table I'm stuck. I have not found how to make select queries with talend not know how I started that can help me please
To make a select on Oracle schema you need a tOracleInput component instance. You need to specify a Oracle connection (either a builtin connection or a repository-registered connection) and the output schema (the columns you need).
Then, click on "Guess query" to build the select SQL code accordingly to your desired output schema. You can then modify the automatically generated SQL code to fit your needs (ie. add WHERE or SORT clauses). Don't forget that output schema and selected columns must be the same (ie if you add a SQL-generated column inside the select clause you must add in your output schema, too). Any valid SELECT syntax can be used here (including subselects, cursors, window over partition and even more weird oracle stuff).
After the input instance, add a tMap where you make all your data manipulations. Finally, close with a tMySqlOutput, specifing connection and output table details. The flow will trivially looks like:
tOracleInput ----> tMap ----> tMySqlOutput
Create the connection Mysql and Oracle in Metadata Objects (Db Connections).
Create the following objects (tMySqlConnection - TOracleConnection)
Configure the objects with the parameters connections (Property Type: Repository).
Extract data: You can select the table with the object tOracleInput.
Edit schema of the table in the submenu Component
Create object TMAP, (transform the data)
Create object tMysqlOutPut and configure the schema and columns to insert.
Create object tMysqlCommit and close the connection.
Listo! ¡¡Run to job!! :)

how to create Oracle DBLink in same SID

Please let me know how to create Oracle DBLink in the same SID for two schema? To make clear, I want to connect one schema to another schema in the same Oracle server (SID).
Let's say, I have two schema called sch1 and sch2. Now, I login as sch1 and what I want is to retrieve data from sch2 (as long as I'm in sch1).
If you want to access a table in one schema from another schema, try doing the following:
connect as schema2,
run grant select on sometable to schema1,
connect as schema1,
try select * from schema2.sometable.

How should I read the data from different oracle schema using ado.net?

The database user has got two schemas. I need to read the data from a specific schema using ado.net. I am using OleDbConnection object to create the connection to database. Appreciate your answers.
Use SCHEMA_NAME.TABLE_NAME in your queries.
If you don't specify a schema, Oracle will look into the current schema. The schema is by default the connexion user (so if you connect with USER1 and query TABLE1, Oracle will look for the table USER1.TABLE1). You can change your current schema at any time during a session with:
ALTER SESSION SET CURRENT_SCHEMA=SCHEMA2;
You can also use synonyms to point to the correct table.

Possible to link to another database link?

We have an existing database link in an Oracle database that links to data in a Sql Server database. Now, a 2nd Oracle database needs to use that same data. Due to security setup, the 2nd Oracle database cannot "see" the Sql Server database, but it can see the 1st Oracle database.
If we create a database link in the 2nd Oracle database that points to the 1st Oracle database, will we be able to query data from the Sql Server database in the 2nd Oracle database by going through 2 database links? Would the query syntax look like this:
SELECT * FROM myTable#2ndLink#1stLink
Has anyone done something like this before?
Vincent's solution will work, and another solution is to create a synonym instead of a view.
DB1:
CREATE SYNONYM X FOR MyTable#sqlServerDB
DB2:
(assumes db link to DB1 connects as owner of synonym)
SELECT * from X#DB1
I'm not sure this synthax would work (although it would be interesting to test it I can not do it right now). However, even if it doesn't work, you can still create a view in Database 1 that points to a table in your SQL Server Database. From Database 2, you could then query:
SELECT * FROM myView#db1
That would point to the correct table.

Resources