許可權管理 角色管理

2021-09-08 21:15:19 字數 2949 閱讀 8933

下面示圖為角色管理介面。在資料表[role]中,最少需要兩個字段[roleid]和[rolename]。project中所有角色在此介面進行管理。

下面為表[role]結構,直接拷貝在sql server2008查詢分析器執行:

et ansi_nulls 

ongo

setquoted_identifier 

ongo

create

table

[dbo].

[role](

[roleid][

smallint

]identity(1

,1) not

null,[

rolename][

nvarchar](

50) 

notnull,[

description][

nvarchar](

100) 

notnull

,primary

keyclustered([

roleid

]asc

)with

(pad_index  

=off

, statistics_norecompute  

=off

, ignore_dup_key 

=off

, allow_row_locks  =on

, allow_page_locks  =on

) on

[primary],

constraint

[uk_role_ud980sa6

]unique

nonclustered([

rolename

]asc

)with

(pad_index  

=off

, statistics_norecompute  

=off

, ignore_dup_key 

=off

, allow_row_locks  =on

, allow_page_locks  =on

) on

[primary]) 

on[primary]go

插入的儲存過程usp_role_insert:

setansi_nulls 

ongo

setquoted_identifier 

ongo

create

procedure

[dbo].

[usp_role_insert](

@rolename

nvarchar(50

),@description

nvarchar(50

))asselect

[rolename

]from

[role

]where

[rolename]=

@rolename

if@@rowcount

>

0begin

raiserror(n'

此角色已經存在,無法新增!',

16,1)

return

endelse

begin

transaction

declare

@err

intinsert

into

dbo.role(

[rolename],

[description]) 

values

(@rolename

,@description

)set

@err

=@@error

if@err

<>

0begin

rollback

transaction

endcommit

transaction

最後即是更新的儲存過程usp_role_update:

setansi_nulls 

ongo

setquoted_identifier 

ongo

create

procedure

[dbo].

[usp_role_update](

@idtinyint

,@rolename

nvarchar(50

),@description

nvarchar(50

))asselect

[rolename

]from

[role

]where

[rolename]=

@rolename

and[

roleid

]<>

@idif

@@rowcount

>

0begin

raiserror(n'

此角色已經存在,無法更新!',

16,1)

return

endelse

begin

transaction

declare

@err

intupdate

[role

]set

[rolename]=

@rolename,[

description]=

@description

where

[roleid]=

@idset

@err

=@@error

if@err

<>

0begin

rollback

transaction

endcommit

transactiongo

許可權管理 角色管理

下面示圖為角色管理介面。在資料表 role 中,最少需要兩個字段 roleid 和 rolename project中所有角色在此介面進行管理。下面為表 role 結構,直接拷貝在sql server2008查詢分析器執行 et ansi nulls ongo setquoted identifie...

mysql許可權角色管理

程式中可能需要保留root使用者的許可權,進行資料的增刪改查,但是平時程式設計師連線mysql資料庫的時候使用root許可權容易造成誤操作,給mysql造成嚴重的損失。於是需要單獨建立程式設計師賬戶供其在平時工作中查詢資料庫。mysql h host uroot p mysql 1.建立乙個管理員使...

基於許可權的角色管理

1.基於角色的許可權管理介紹 rbac 得到乙個專案要搞懂兩點 首先看懂需求 表設計出來 業務 無非就是操作的表不一樣,搞清楚往那張表裡寫,從那張表裡讀就可以了 基於角色的許可權管理至少得四張表 使用者表 多戶n 角色1 角色表 為了分配資源簡單化,因此給使用者配角色即可以了 角色n 資源n 資源表...