資料庫授權操作

2022-03-30 00:08:55 字數 1420 閱讀 2169

use dbname

go--1.1 新增登入使用者和密碼

exec sp_addlogin n'testlogin','123456'

--1.2 使其成為當前資料庫的合法使用者

exec sp_grantdbaccess n'testlogin'

--2.設定操作授權

--2.1 授予對自己資料庫的所有許可權

exec sp_addrolemember n'db_owner', n'testlogin'

--2.2 以下是設定具體操作許可權

--授予testlogin對所有使用者表的操作許可權

grant select,insert,update,delete to testlogin

--授予testlogin select,update到具體的表

grant select,update on tb to testlogin

--授予testlogin select,update到具體的表和列

grant select,update on tb(id,col) to testlogin

--禁止testlogin對所有使用者表的操作許可權

deny select,insert,update,delete to testlogin

--禁止testlogin select,update到具體的表

deny select,update on tb to testlogin

--禁止testlogin select,update到具體的表和列

deny select,update on tb(id,col) to testlogin

--刪除testlogin 對所有使用者表的授權資訊

revoke select,insert,update,delete to testlogin

--授予testlogin對具有建立表、檢視、儲存過程等的操作許可權

grant create table,create view,create proc to testlogin

--禁止testlogin對具有建立表、檢視、儲存過程等的操作許可權

deny create table,create view,create proc to testlogin

--刪除testlogin對具有建立表、檢視、儲存過程等的授權資訊

revoke create table,create view,create proc to testlogin

--3. 刪除測試使用者

exec sp_revokedbaccess n'testlogin' --移除使用者對資料庫的訪問許可權

exec sp_droplogin n'testlogin' --刪除登入使用者

go

資料庫授權操作

use dbname go 1.1 新增登入使用者和密碼 execsp addlogin n testlogin 123456 1.2 使其成為當前資料庫的合法使用者 execsp grantdbaccess n testlogin 2.設定操作授權 2.1 授予對自己資料庫的所有許可權 execs...

mysql資料庫授權

授權命令grant 語句的語法如下 grant privileges columns on what to user identifiedby password with grant option 對使用者授權 mysql grant rights on database.to user host ...

資料庫之授權

本篇文章主要介紹mysql資料庫的授權,以下內容是筆者學習 資料庫系統概念 總結而來,權當筆記。我們可能會給乙個使用者在資料庫的某些部分授予幾種形式的許可權,包括 授權讀取資料 授權插入新資料 授權更新資料 授權刪除資料。每種型別的授權都稱為乙個許可權 privilege 我們可以在資料庫的某些特定...