sql用戶許可權查看
1.在資料庫本機用使用cmd指令調出命令行窗口,再用sqlplus/assysdba登錄到資料庫中。並且用對要賦許可權的表所有者連接資料庫,否則後續賦許可權會失敗。
B. sql server 查看 賬號 擁有哪些許可權
1.把你的用戶自定義資料庫放入一個系統提供的資料庫。系統提供的資料庫有:db_owner,db_accessadmin,db_securityadmin,db_ddladmin,db_backupoperator,db_datareader,db_datawriter,db_denydatareader和db_denydatawriter。
2.把用戶自定義資料庫添加到將作為開發環境的db_datareader和db_datawriter中。如果已經有一個可以添加和/或刪除用戶自定義資料庫對象的開發環境,就只需要取消這個許可權或是把用戶自定義資料庫添加到db_ddladmin系統資料庫中。
3.把資料庫用戶作為資料庫成員添加到你的用戶自定義資料庫中。
4.取消所有的公共許可權。
不要向公共用戶發出DENY命令。如果你向公共用戶發出了DENY命令,用戶將不能讀取用戶自定義資料庫的對象。用REVOKE命令代替DENY命令來取消讀取公共資料庫的許可權。這樣設置後,資料庫的用戶就是用戶自定義資料庫的成員了。用戶自定義資料庫具有讀取用戶自定義資料庫對象的許可權。因此這個用戶自定義資料庫允許資料庫用戶讀取用戶自定義資料庫的對象。
C. sql server 怎麼查看用戶
SQL Server中查詢用戶的對象許可權和角色的方法
-- 查詢用戶的object許可權
exec sp_helprotect NULL, 'UserName'
-- 查詢用戶擁有的role
exec sp_helpuser 'UserName'
-- 查詢哪些用戶擁有指定的系統role
exec sp_helpsrvrolemember 'sysadmin'
-- 可查詢嵌套role
WITH tree_roles as
(
SELECT role_principal_id, member_principal_id
FROM sys.database_role_members
WHERE member_principal_id = USER_ID('UserName')
UNION ALL
SELECT c.role_principal_id,c.member_principal_id
FROM sys.database_role_members as c
inner join tree_roles
on tree_roles.member_principal_id = c.role_principal_id
)
SELECT distinct USER_NAME(role_principal_id) RoleName
FROM tree_roles
-- 其他許可權相關基本表
select * from sysusers
select * from syspermissions
-- Who has access to my SQL Server instance?
SELECT
name as UserName, type_desc as UserType, is_disabled as IsDisabled
FROM sys.server_principals
where type_desc in('WINDOWS_LOGIN', 'SQL_LOGIN')
order by UserType, name, IsDisabled
-- Who has access to my Databases?
SELECT
dp.name as UserName, dp.type_desc as UserType, sp.name as LoginName, sp.type_desc as LoginType
FROM sys.database_principals dp
JOIN sys.server_principals sp ON dp.principal_id = sp.principal_id
order by UserType
select * from sys.database_principals
-- Server Roles
select
p.name as UserName, p.type_desc as UserType, pp.name as ServerRoleName, pp.type_desc as ServerRoleType
from sys.server_role_members roles
join sys.server_principals p on roles.member_principal_id = p.principal_id
join sys.server_principals pp on roles.role_principal_id = pp.principal_id
where pp.name in('sysadmin')
order by ServerRoleName, UserName
-- Database Roles
SELECT
p.name as UserName, p.type_desc as UserType, pp.name as DBRoleName, pp.type_desc as DBRoleType, pp.is_fixed_role as IfFixedRole
FROM sys.database_role_members roles
JOIN sys.database_principals p ON roles.member_principal_id = p.principal_id
JOIN sys.database_principals pp ON roles.role_principal_id = pp.principal_id
where pp.name in('db_owner', 'db_datawriter')
-- What can these users do?
SELECT
grantor.name as GrantorName, dp.state_desc as StateDesc, dp.class_desc as ClassDesc, dp.permission_name as PermissionName ,
OBJECT_NAME(major_id) as ObjectName, GranteeName = grantee.name
FROM sys.database_permissions dp
JOIN sys.database_principals grantee on dp.grantee_principal_id = grantee.principal_id
JOIN sys.database_principals grantor on dp.grantor_principal_id = grantor.principal_id
where permission_name like '%UPDATE%'