Schema name prefix issue in SQL query - oracle

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

Related

The problem of openGauss database connection schema

we encountered a problem when migrating the database from oracle to guassdb. It is a compatible version with postgresdb, which uses schema,
For example, select * from table1
Now because gauss uses schema, our table is in a01
The query becomes select * from a01.table1, which causes all the codes to be changed during the migration. The schema is added to the front of each table name, which is too big. Is there a better solution, such as adding schema to the url connection, because we only use one schema for each project
You can configure the user's search_path in the openGauss database. This parameter can also be configured through the url parameter in the jdbc.
for example: jdbc:postgresql://localhost:5432/mydatabase?currentSchema=a1

How to drop database in H2?

I use the sql statement DROP DATABASE KEYCLOAK; This throws a syntax error in h2 console.
error
drop database keycloak;
Syntax error in SQL statement "DROP DATABASE[*] KEYCLOAK "; expected "TABLE, INDEX, USER, SEQUENCE, CONSTANT, TRIGGER, VIEW, ROLE, ALIAS, SCHEMA, ALL, DOMAIN, TYPE, DATATYPE, AGGREGATE"; SQL statement:
drop database keycloak [42001-193] 42001/42001 (Help)
There does not seem to be any error in syntax. Please help.
If you really need to drop the whole database in H2 Console, use
DROP ALL OBJECTS DELETE FILES;
SHUTDOWN;
You'll see “Database is already closed” error or something like it after execution of SHUTDOWN command, it should be ignored.
If you want to drop only your schema (in some other DBMS the “database” term is used for a schema, but in H2 they are different things), use
DROP SCHEMA schemaName;
where schemaName is a name of your schema.
Note: the PUBLIC schema cannot be dropped and there are no commands to clear all its content at once. But there is a command to drop all other objects in the database, it is the same
DROP ALL OBJECTS
command, but without DELETE FILES clause. It preserves only the current user, the PUBLIC role, and the empty PUBLIC schema (content of this schema is dropped).
All these commands are destructive and cannot be rolled back.
You might be facing an error because you are trying to drop database that doesn't exist. Try this following options.
Drop Table: Drop Table is a command that deletes the respective table and its structure.
DROP TABLE TABLE_NAME;
Drop Schema:Drop Schema is a command that drops a respective schema from the database server. It will not work from the current schema.
DROP SCHEMA SCHEMA_NAME;

Discovering tables on an Oracle Database return an empty list

When creating a connection to an Oracle database in icCube 'Select existing DB Tables' is returning an empty list of tables.
The connection is fine and I can query the schema creating SQL queries.
The user is used as the schema name, but Oracle uses upper case as default for the schema names. The connection uses the user that is case insensitive.
Just, change the name of your user to the upper case version : USER_1

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.

Resources