I am using snowflake jdbc, while querying for a table in an invalid schema name, Snowflake still tries to search it in public schema. Is it snowflake's default behaviour? Can I override/change it and throw exception if not found in input schema name ?
For example, I am trying:
select *
from mydb.test_schema_invalid.table_1;
This schema is not present in my database, but this table is present in public schema, so snowflake is still giving me results for this
Related
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;
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
Let's say that my database has the following objects:
A table on schema "B" named "mlb_players"
A view on schema "C" named "mlb_players" that is a SELECT against a table on server "DB2"
A synonym on schema "D" named "mlb_players" that points to a table on server "DB3"
All of these objects are granted to my schema "RedSoxRule"
If I execute this query, from where would the data be retrieved?
SELECT *
FROM mlb_players
In other words, if a given name (in this case "mlb_players") is applicable to different object types, and the GRANTS are equal, in what order will Oracle find the requested object?
Oracle has a nice long explanation of this.
Basically, when resolving a name, it looks:
For objects in your schema with that name
For public synonyms with that name
If the name has multiple parts (e.g. C.mlb_players, it checks to see if the first part is a qualifying schema that you have access to.
In your example, Oracle won't find any of them. They're all in different schemas from your RedSoxRule schema, none of them are public synonyms, and you didn't qualify mlb_players with a schema name.
It doesn't actually matter what the type of the object is (table, view, synonym, package, etc) - they're all treated the same.
If I execute this query, from where would the data be retrieved
Nowhere. REDSOXRULE has no object called mlb_players so the query would fail with ORA-00942: table or view does not exist.
You would need to prefix the table name with the schema you're prefixing, e.g.
SELECT *
FROM d.mlb_players;
Let's suppose you have a variation on your posted structure.
REDSOXRULE has a view mlb_players for a.mlb_players. The query select * from mlb_players would select from this view, i.e from a.mlb_players.
Instead of a view REDSOXRULE has a private synonym mlb_players for b.mlb_players. The query select * from mlb_players would select from this synonym, i.e from b.mlb_players. Note that you can't have a private synonym with the same name as a table or view in your schema.
Instead of a private synonym the database has a public synonym mlb_players for d.mlb_players. The query select * from mlb_players would select from this publicsynonym, i.e from d.mlb_players.
That is, Oracle looks first for objects owned by the schema (tables, views, private synonyms, etc). Then it looks at public synonyms. Then it looks for objects in other schemas
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
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.