SQL SERVER 檢視使用者許可權

2021-06-27 11:00:32 字數 2401 閱讀 9697

--使用者與角色關係

select a.uid as uid,a.status as ustatus,a.name as uname,

b.uid as rid,b.status as rstatus,b.name as rname

from sysusers a left join sysmembers m on m.memberuid = a.uid 

left join sysusers b on b.gid = m.groupuid

where a.issqluser =1

--a.islogin =1

--b.issqlrole

--使用者或角色在資料庫中的授權資訊

select b.id,b.name as tname,b.type,a.uid,c.name as uname,a.action,a.protecttype,a.columns

from sysprotects a inner join sysobjects b on a.id = b.id

inner join sysusers c on a.uid = c.uid

where a.uid > 0

或則select object_name(a.id) as tname,a.uid,c.name as uname,a.action,a.protecttype,a.columns

from sysprotects a  inner join sysusers c on a.uid = c.uid

where a.uid > 0

或則select b.name as tname,c.name as objname,

case b.type

when 'u' then 'table'

when 'p' then 'sp'

else 'other'

end as type,

case when  a.action = 26 and a.protecttype = 205 then '√' else '' end as 'references',

case when  a.action = 193 and a.protecttype = 205 then '√' else '' end as 'select',

case when  a.action = 195 and a.protecttype = 205 then '√' else '' end as 'insert',

case when  a.action = 197 and a.protecttype = 205 then '√' else '' end as 'update',

case when  a.action = 196 and a.protecttype = 205 then '√' else '' end as 'delete',

case when  a.action = 224 and a.protecttype = 205 then '√' else '' end as 'execute',

case a.protecttype

when 204 then 'grant_w_grant '

when 205 then 'grant'

when 206 then 'deny'

else 'other'  --當有other出現的時候,需要將其他的protecttype新增進去。

end as protecttype

from sysprotects a inner join sysobjects b on a.id = b.id

inner join sysusers c on a.uid = c.uid

where c.name in ('m18console')

order by tname

--組織授權sql

select 

'grant '+ case a.action 

when 26 then 'references' 

when 193 then 'select' 

when 195 then 'insert' 

when 196 then 'delete' 

when 197 then 'update' 

when 224 then 'execute' 

else 'other' --當有other出現的時候,需要將其他的action型別新增進去。 

end +' on '+ b.name +' to '+ c.name

from sysprotects a(nolock) inner join sysobjects b(nolock) on a.id = b.id 

inner join sysusers  c (nolock)on a.uid = c.uid 

where a.uid > 0  and c.name = 'm18style'

oracle檢視使用者許可權

1.檢視所有使用者 select from dba users select from all users select from user users 2.檢視使用者或角色系統許可權 直接賦值給使用者或角色的系統許可權 select from dba sys privs select from u...

mysql 檢視使用者許可權

show grants for root localhost grant usage on to discuz localhost identified by password c242ddd213be9c6f8da28d49245bf69fc79a86eb grant all privileges...

mysql檢視使用者許可權

原文 如果需要檢視mysql使用者許可權,應該如何實現呢?下面就為您介紹檢視mysql使用者許可權的方法,並對授予mysql使用者許可權的語句進行介紹,供您參考。檢視mysql使用者許可權 show grants for 你的使用者 比如 show grants for root localhost...