数据库角色管理,已经可以使用alter role,create role和drop role。
2012增加了几个ddl语句,可以操作服务级别的角色管理,
CREATE SERVER ROLE
用来创建服务级别的role。
CREATE
SERVER
ROLE
DBA
SELECT
name
,
type_desc
FROM
sys
.
server_principals
WHERE
type
=
'R'
AND
name
=
'DBA'
name
type_desc
-------------------------------------- ------------------------------------------------------------
DBA SERVER_ROLE
ALTER SERVER ROLE
用来修改服务级别的角色
ALTER
SERVER
ROLE
DBA
ADD
MEMBER fanr
SELECT
b
.
name
,
c
.
name
FROM
sys
.
server_role_members
a
INNER
JOIN
sys
.
server_principals
b
ON
a
.
role_principal_id
=
b
.
principal_id
INNER
JOIN
sys
.
server_principals
c
ON
a
.
member_principal_id
=
c
.
principal_id
WHERE
b
.
name
=
'DBA'
name name
---------------------------------------
DBA fanr
ALTER
SERVER
ROLE
dba
DROP
MEMBER fanr
SELECT
b
.
name
,
c
.
name
FROM
sys
.
server_role_members
a
INNER
JOIN
sys
.
server_principals
b
ON
a
.
role_principal_id
=
b
.
principal_id
INNER
JOIN
sys
.
server_principals
c
ON
a
.
member_principal_id
=
c
.
principal_id
WHERE
b
.
name
=
'DBA'
name name
-------------------------- ---------------------
(
0
row
(
s
)
affected
)
DROP SERVER ROLE
删除服务级别角色
DROP
SERVER
ROLE
dba