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

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.

Related

Data replication between Oracle and Postgres

Is there a way to replicate data(like triggers or jobs) from oracle tables to postgres tables and vice versa(for different set of tables) without using external tools? Just one way replication for both the scenarios.
Just a hint:
You can think of create a DB link from Oracle to Postgres which is called heterogeneous connectivity which makes it possible to select data from Postgres with a select statement in Oracle.
Then use materialized views to schedule and store the results of those selects.
As you don't want to use any external tool otherwise the solution should have been much simpler
for 20 tables I need to replicate data from oracle to postgres. For 40 different tables, I need to replicate from postgres to oracle.
I could imagine the following setup:
For the Oracles tables that need to be accessible from Postgres, simply create foreign tables inside the Postgres server. They appear to be "local" tables in the Postgres server, but the FDW ("foreign data wrapper") will forward any request to the Oracle server. So no replication required. Whether or not this will be fast enough depends on how you access the tables. Some operations (WHERE clause, ORDER BY etc) can be pushed down to the Oracle server, some will be done by the Postgres server after all the rows have been fechted.
For the Postgres tables that need to be replicated to Oracle you could have a similar setup: create a foreign table that points to the target table in Oracle. Then create triggers on the Postgres table that will update the foreign table, thus sending the changes to Oracle.
This could all be managed on the Postgres side.

Is the Oracle_SID the same the login name on Oracle?

I come from an SQL Server/Sybase background.
I'm used to referring to tables in a particular schema, in the format:
SCHEMA_NAME..TABLE_NAME.
I asked a colleague today about creating a fresh 'schema' on an Oracle database. His response was:
On Oracle you get the Schema name of the logged in user. The schema name is the same as the login user name.
That didn't sound quite right to me. I'm guessing this is an oversimplification, or some concepts are mixed up.
My assumption is the that Oracle_SID is the same as my concept of 'schema' from the Sybase world.
My question is: Is the Oracle_SID the same the login name on Oracle?
Your colleague is right. A schema and a user are pretty much the same in Oracle. When you create a user, a schema with the same name is automatically created.
Quote from the manual:
A schema is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema
There is no concept of a "database" the way there is in Sybase or SQL Server.
The SID is the identifier for an instance which is something completely different.
A fully qualified table name in Oracle only consists of two elements: the schema (=owner) and the object name: schema_name.table_name and they are separated by a single .
My question is: Is the Oracle_SID the same the login name on Oracle?
The answer to that is: NO, absolutely not
The Oracle System ID (SID) is used to uniquely identify a particular database on a system. For this reason, one cannot have more than one database with the same SID on a computer system.
When using RAC, all instances belonging to the same database must have unique SID's.
A schema is a collection of logical structures of data, or schema objects. A schema is owned by a database user and has the same name as that user. Each user owns a single schema.
refer http://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm
you may find the difference between schema vs user
https://dba.stackexchange.com/questions/37012/difference-between-database-vs-user-vs-schema
Oracle SID is beside the point of login name. SID is the identifier of Oracle instance.
Oracle historically considers SCHEMA, ROLE and USER as a very close terms and has common implementation for them. For example, you can create something using command CREATE USER and then drop it using command DROP SCHEMA.

Schema name prefix issue in SQL query

I have WMADMIN schema. This schema is configured as connection credential in websphere datasource.
I have table in other schema/user OCS_JOBS. But the problem is my application looking for the table in WMADMIN schema.
It looks i need to prefix schemaname OCS_JOBS in SQL query to run them.
Is there any other way to run the SQL query the table which is in other user/schema without prefixing the other schema name
You can create a SYNONYM see it here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm

SSIS breaks Oracle Privileges

I make a privileges to user on one schema at Oracle, when accessing oracle database using SSIS I saw all tables and schema. When I use SQL Plus show me only one schema.
What is the problem here?
What query are you running to see tables in SQL*Plus? If you are querying USER_TABLES, you will only see the tables that the current user owns. If you are querying ALL_TABLES, you will see all the tables that you have permission to query regardless of the owner. If you are querying DBA_TABLES, you will see all the tables in the database (though you need additional privileges to query the DBA% objects.
There is another question on how to get a list of all the tables in a database that goes into more detail about this.

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.

Resources