SQL Server permissions to only one table for specific users - sql

I have a database with many users who have access to all tables within the DB. There is one table that I would like to restrict access to only a specific few users. So basically granting table access to some while removing table access to the rest. Any thoughts on best way to accomplish this?

You could always DENY SELECT to all users on that table, and then grant it by person for the few you do want to have access to it.
DENY Object Permissions (Transact-SQL)
This question may also help you: SQL Server : can you limit access to only one table

Related

Deny Update on Columns to ALL Users & Roles

In SQL Server, I have a table where after a row has been inserted, several of the columns never need to be changed (yes it's possible this might change in the future, but unlikely or will be a rare event). I know that SQL server has column level permissions, and so I wanted to deny updated on these columns for all users, role, current and present. The T-SQL looks something like this:
DENY UPDATE ON dbo.<Table>(<Column1>,<Columns2>,etc) TO ______
However it appears that using this command, you have to always specify a user or role at the end. Is there a way to have it apply to all users current and future?
And yes, I AM WELL AWARE I can use a trigger to throw an error if the columns are changed after an update, or apply the DENY command to all existing users and roles and create a procedure for creating new users and roles that would create the new user/role and automatically apply the update, etc.
Before I consider any of those options, I would see if the DENY Update to all Users option can be done.
Thanks you!
Enrole all your SQL users in a default role, so that you can do a DENY on that role. For the future one, create a DDL trigger that fire CREATE USER and add it as a member of this role.

In SQLServer 2012 how can i SELECT from a view when access to underlying table is ecplicitly DENYied

I have a table on which I had to DENY SELECTs to some users (REVOKE didn't work as all the SELECTs were GRANTed at DB level).
However, to these users, I want to give SELECT permissions on a VIEW which SELECTs from this table.
On reading about permissions in SQLServer I have found that one cannot override a DENY.
Is there any another way to achieve this?
The only way with the following rights to enable reading the view would be to have the same owner of the View and the Table.
If you can't do it, you will have to give the rights to the table explicitely, or review the ENTIRE rights mapping.

Make User To Interact With only One Table on Database?

I have DataBase that have more than 200 tables in it.
I need to give user access to only one table.
I'm using SQL Server 2005.
Can you please suggest how can I grant access to user to only one table.
use grant
GRANT INSERT ON YourTable TO SomeUser

SQL server - privileges to get metadata of database

What minimum privileges my user needs to get metadata (name of tables, columns, procedures, etc.) from database?
I need to select from:
[database].sys.objects
[database].sys.schemas
[database].sys.extended_properties
[database].sys.sql_modules
[database].information_schema.columns
db_datareader is ok, but I need minimum privileges.
In order to let user only query metadata of objects, just give him the VIEW ANY DEFINITION permission, as described here:
http://msdn.microsoft.com/en-us/library/ms175808(v=sql.105).aspx

Oracle: control access to data through views?

I have a problem with controling access to data in a database. The data is a mix of price-data from my company and price-data bought from a data-provider and since they charge per user who can access their data I need to be able to limit the access to data.
I have a scheme "DATA" which holds all price-data. I am thinking having 2 additional schemes (example: LIM_ACCESS and FULL_ACCESS) with VIEWS that is build on the DATA-scheme. example:
CREATE VIEW LIM_ACCESS.V_PRICES AS<br>
SELECT [] FROM DATA.PRICES<br>
WHERE SOURCE = [MyCompany]
CREATE VIEW FULL_ACCESS.V_PRICES AS<br>
SELECT [] FROM DATA.PRICES
But to my experience then the LIM_ACCESS- and FULL_ACCESS-schemes has to have select-privelige on the DATA-tables to create the views and then I am back to square 1.
Being a novice in databases I feel there must be a relative simple solution to this so any advice or hint(if this question has been asked and answered before) is appreciated :-)
Kind Regards,
Svend
You can put all the views in your DATA schema. Then GRANT SELECT on them to other schemas as necessary, ideally via database roles as Woot4Moo suggested.
The use of a view will not prevent a subset of users from accessing the data. What you need to do is implement row level security.
Another approach is to use some form of role based permissions, that enable only the specific group of users you want to access the "paid" information. This can be done fairly trivially example follows.
create user foo
identified by password;
--no permissions
create role paid_data;
--grant privileges here for the paid_data role
grant paid_data to foo
User foo will now have the permissions that the paid_data role has. The advantage of using roles like this is that you can quickly revoke everyone's access that is in that group / add more accesses as they need to be incorporated.
As GriffeyDog suggested, this is the best way to do it. First create two views in your schema and then grant select on those views to the two users.
CREATE VIEW LIM_ACCESS_V_PRICES AS<br>
SELECT [] FROM DATA.PRICES<br>
WHERE SOURCE = [MyCompany];
GRANT SELECT ON LIM_ACCESS_V_PRICES TO LIM_ACCESS;
CREATE VIEW FULL_ACCESS_V_PRICES AS<br>
SELECT [] FROM DATA.PRICES;
GRANT SELECT ON FULL_ACCESS_V_PRICES TO FULL_ACCESS;
Another approach is to use Oracle Row Level Security otherwise known as Oracle Label Security. I've used this to greatly simplify my application design while ensuring users only see the data they're allowed to see.