Which Oracle database role will allow a user to select from a table in another schema without specifying the schema identifier?
i.e., as user A- Grant select on A.table to user B;
B can then- "Select * from table" without specifying the 'A'.
One of our databases allows this, the other returns a 'table or view does not exist' error.
You can create a synonym for this. Create a synonym named "CoffeeTable" on object "A.CoffeeTable". You can create a public synonym so everyone sees it like this, or just a synonym under user B.
Just to double check that the schema you are using doesn't have a private synonym for the table (or a view as Leigh suggests) you could the following
SELECT * FROM all_objects WHERE object_name = 'mytablename'
and look at the owner and object_type information.
Maybe only the current_schema is different. Try:
alter session set current_schema=A
If there isn't a synonym, is there a view in schema B that selects from the table in schema A using the same name as the table? This would appear to be a locally referenced table in many ways.
Brett is right. Synonyms are used for this. In fact there are cases where you do not know what will be the schema name in production. Maybe you use A for some schema name and A is already taken in some Oracle instance.
#erno - probably the reason that TOAD didn't show you the public synonym is because it filters the information shown in the list - I don't have toad in front of me but I think if you right click on tab you will get to the filtering options (eg "only show objects owned by the schema", "show public objects", "show system objects" etc)
Related
I understand that we can do "show databases" in snowflake to get the details of databases. But is there any admin table which i can query.
Actually in my result set I need only database names.
There is an option to use RESULT_SCAN but i am trying to avoid the same.
please advise.
You can use INFORMATION_SCHEMA , and in particularINFORMATION_SCHEMA.DATABASES`, e.g.
SELECT * FROM INFORMATION_SCHEMA.DATABASES
I have a query in classic asp where SQL statement is this:
Select * from active_Case
I verified in the DB connection it is using and found there is no such table / view. But a table does exist by the name of Cases. Internally it appears to be selecting from this table itself.
Actually this is somebody else's code. Thus I am not sure how is it possible. Is it really possible or am I missing something?
this will give you the base table name
select name, base_object_name
from sys.synonyms
where name = 'active_Case'
other than tables and view you can even check in User defined table type under types. or there might be chance your table is having a schema other than 'dbo.'
How can I restrict some users in DB2, not to see the table structure. I set the user privilege and restrict user from table access. so that user can not select data or change table but still can see the table structure or describe it.
This problem refers to row access in tables which is added in db2 version 10.
I had this problem too.
you can use this version - if applicable- and restrict user access from specific table structures.
You need to remove the select grant on catalog tables. For example, the following query should return 0 rows when executing with q restricted user.
db2 "select tabschema, tabname from syscat.tables"
All tables and views in the following schemas should not have select on public, nor in any group the restrictive user is in.
sysibm
syscat
db2 revoke select on SYSIBM.SYSTABLES from username
We have an Oracle DBMS (11g) and the following configuration:
A DB user "MYUSER"
Two schemas "MYUSER" and "SCHEMA_B"
User "MYUSER" can access "SCHEMA_B" and has READ permissions on its tables
A public DB link "DB_LINK" located in "SCHEMA_B"
The DB_LINK is working when using the DB user "SCHEMA_B" directly
Question: When logged on as "MYUSER", what is the correct syntax to access tables using the DB link of "SCHEMA_B"? Is it possible to do so at all?
I already tried several constellations, which all did not work:
select * from dual#"DB_LINK"
select * from dual#"SCHEMA_B"."DB_LINK"
select * from dual#SCHEMA_B."DB_LINK"
select * from dual#SCHEMA_B.DB_LINK
select * from SCHEMA_B.dual#DB_LINK
select * from "SCHEMA_B".dual#DB_LINK
The error message I receive is:
ORA-02019. 00000 - "connection description for remote database not found"
Thanks for any suggestion!
I don't think it is possible to share a database link between more than one user but not all. They are either private (for one user only) or public (for all users).
A good way around this is to create a view in SCHEMA_B that exposes the table you want to access through the database link. This will also give you good control over who is allowed to select from the database link, as you can control the access to the view.
Do like this:
create database link db_link... as before;
create view mytable_view as select * from mytable#db_link;
grant select on mytable_view to myuser;
I had the same problem
I used the solution offered above -
I dropped the SYNONYM, created a VIEW with the same name as the synonym.
it had a select using the dblink ,
and gave GRANT SELECT to the other schema
It worked great.
I have a database FooDb with a schema BarSchema that contains a table Tbl (i.e. FooDb.BarSchema.Tbl)
I am also logged in as a user with BarSchema as default.
This query works fine
SELECT * FROM FooDb..Tbl
I also have a synonym for this table in another db
CREATE SYNONYM TblSynonym FOR FooDb..Tbl
But now I get an error "Invalid object name 'FooDb..Tbl'" when executing
SELECT * FROM TblSynonym
If i change the synonym to
CREATE SYNONYM TblSynonym FOR FooDb.BarSchema.Tbl
it works fine.
Why doesn't the default schema work in synonyms?
(The background is that I'm consoldating data from several databases which all got same table names but different schema names. It would be a lot easier if I could set the default schema for each database on the user and then ignore it everywhere in the script)
The documentation suggests the db..tbl syntax should work:
schema_name_2 Is the name of the
schema of the base object. If
schema_name is not specified the
default schema of the current user is
used.
This works for me in SQL Server 2008:
create synonym TestSynonym for TestDB..TestTable
One cause might be that the default schema is associated with the user, not the database. Check if your user has an unexpected default schema? In my SSMS, that setting is located under Database -> Security -> Users -> Properties.