Grant Privileges in Oracle 10g - database

I am new to databases. Here I have logged in the user account:System
I then create a new user raj using the following command
create user raj identified by raj
Then I connected to the user raj using following command
grant connect to raj
Here I am granting privileges on the table client_master to raj
grant all on client_master to raj
Now I want to select the contents of table client_master
select * from raj.client_master
but it is giving an error that such table does not exist.

A quick search on google and you would find out that the select right is as simple as select.
grant select on client_master to raj;
However, it is not the real problem as when executing this command grant all on client_master to raj the select privilege is already included.
So here are the possibilities why you get this error :
The table does not exist (you need to create it).
It is in another schema, and you did not specify it.
You made a typo when writing client_master.
My guess is that you created the table in sys schema (which is really a bad idea btw) so the problem is the option 2 in the one I listed.
Try
select * from sys.client_master;
Note that if you don't want to always specify the prefix, you can create a synonym.
create synonym raj.client_master for sys.client_master;
Then
select * from client_master;
Would work.

Try running below command -
GRANT EXECUTE ON Find_Value TO smith;
This may help you to resolve your issue.

Related

Azure DB - How to give 1 user read-only permission for 1 table

I've been reading many answers but I am too weak at TSQL to filter out what I need.
I created a contained user for 1 DB...
CREATE USER appuser WITH PASSWORD = 'strongpwd';
So I need to allow a user in to read only the contents of 1 table - tableA (there are others in the DB) and do absolutely nothing else in the DB.
I do not want to affect any other users. I just want the user to be able to access the DB via say SSMS, see only tableA (well this is not that important), read it.
There are two ways one is to directly grant explicit SELECT only on Table 1 and the second one is to create a role, grant SELECT to role and addd the user to the role. Typically second way is the preferred way and can be done as below
CREATE ROLE [role_name]
GRANT SELECT ON [Table] to [role_name]
EXEC sp_addrolemember '[role_name]', 'appuser'

ORA-01031: insufficient privileges on insert

There is a change in data type of e one column from NUMBER(4) to VARCHAR2(4).
DBA did the conversion of exiting values.
Now When we are trying insert the record into table using proc * c code it is giving error "ORA-01031: insufficient privileges".
From SQLPLUS we are able to insert the records. After sometime problem gets disappeared. Once DBA rebuild the table and problem disappeared.
This problem occurs after every time we refresh the testing environment with new changes.
Run this line:
grant insert on [table] to [user]
change [table] to your table name and change [user] to your user.
There are some possibilities.
Double check your table privileges by running the following SQL command:
SELECT *
FROM dba_tab_privs tp
WHERE tp.owner = '<YOUR_OWNER>'
AND tp.table_name = '<YOUR_TABLE_NAME>';
In the case your privilege is granted through a role make sure the role is enabled by checking that the GRANTEE above, in this query below, is shown with the attribute "DEFAULT_ROLE" = YES.
SELECT * FROM dba_role_privs rp WHERE rp.grantee = '<USER_RUNNING_THE_INSERT>';
If it's not, and assuming there is no security issues with your DBA and application design, you can enable it by running this:
alter user <YOUR_USER_RUNNING_THE_INSERT> default role all;
Then again, make sure if you're recreating the table, that every time you drop it and create again, you run your grants accordingly.

sybase privileges grant from one shcema to another

I have 2 schemas database1#server and database2#server.
I want to know how to grant priveleges for database2 to read from database1.
example executing in database2:
select * from database1..table1
You will have to make sure the user in database2 is added to database1 (sp_adduser or sp_addalias).
You can find your current user by doing select user_name() and get a list of users within a database by executing sp_helpuser in that database.
Assuming we have db_user1 and dbuser2, we would add the alias like this:
use database1
go
sp_addalias db_user2, dbuser1
go
From that point forward, when db_user2 is accessing database1, it will be with db_user1's credentials, rights and privileges.
If you add the user, instead of adding the alias, then you will have to grant privileges for tables in the schema to the user (or group that the user is a member of).

How to SELECT in Oracle using a DBLINK located in a different schema?

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.

Is there any system defined function to check if user has alter permission?

I am using MS-sql server 2008
I need to know if a user id has "Alter Contraints" permission on one database.
Is there any system defined functions for this ?
This query will show you all the permissions a user has:
select * from fn_my_permissions(NULL, 'DATABASE')
You can also do specific tables, or an entire server.
http://sqltips.wordpress.com/2007/05/28/retreive-current-user-permissions-in-sql-server-2005/
There is HAS_PERMS_BY_NAME()
http://msdn.microsoft.com/en-us/library/ms189802.aspx
Have you seen sys.fn_my_permissions?
http://msdn.microsoft.com/en-us/library/ms176097.aspx
http://www.siusic.com/wphchen/list-all-permissions-a-user-has-in-sql-server-database-error-4064-321.html

Resources