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%'