📄 sql.htm
字号:
login。如果将其指定为 NULL 值的 OUTPUT 变量,则设置 @name_in_db 为 login。当前数据库不必存在
name_in_db。</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
示例</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
sp_grantdbaccess '用户名','在数据库中的别名'<br>
或<br>
use Northwind<br>
go<br>
sp_grantdbaccess @loginame ="Ke_Xiaodong" ,@name_in_db ="KES"</td>
</tr>
</table>
<hr color="#003366" size="1" />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="114">
<tr>
<td width="100%" colspan="4" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
三、删除 Microsoft SQL Server 登录,以阻止使用该登录名访问 SQL Server。</td>
</tr>
<tr>
<td width="3%" rowspan="5" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="99">
</td>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="30">
语法<br />
<b>sp_droplogin</b> [ @loginame = ] 'login'</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
参数</td>
</tr>
<tr>
<td width="3%" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="18">
</td>
<td width="18%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="1">
[@loginame =] 'login'</td>
<td width="76%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="1">
将被删除的登录。login 的数据类型为 sysname,没有默认值。login 必须已经存在于 SQL Server
中。</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
示例</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
sp_droplogin '用户名'</td>
</tr>
</table>
<hr color="#003366" size="1" />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="132">
<tr>
<td width="100%" colspan="4" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
四、从当前数据库中删除安全帐户。</td>
</tr>
<tr>
<td width="3%" rowspan="5" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="117">
</td>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="30">
语法<br />
<b>sp_revokedbaccess</b> [ @name_in_db = ] 'name'</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
参数</td>
</tr>
<tr>
<td width="3%" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="36">
</td>
<td width="18%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="1">
[@loginame =] 'login'</td>
<td width="76%" valign="top" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="1">
是要删除的帐户名。name 的数据类型为 sysname,无默认值。name 可以是 Microsoft? SQL
Server? 用户名或 Microsoft Windows NT? 用户名或组名,而且必须存在于当前数据库中。当指定
Windows NT 用户或组时,请指定该 Windows NT 用户或组在数据库中可被识别的名称(即用 sp_grantdbaccess
添加的名称)。</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
示例</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
sp_revokedbaccess '用户名','数据库名'</td>
</tr>
</table>
<hr color="#003366" size="1" />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="166">
<tr>
<td width="100%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
五、在安全系统中创建项目,使当前数据库中的用户得以处理当前数据库中的数据或执行特定的 Transact-SQL
语句。</td>
</tr>
<tr>
<td width="3%" rowspan="4" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="151">
</td>
<td width="97%" colspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
语法</td>
</tr>
<tr>
<td width="26%" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="8" valign="top">
语句权限:<br />
<b>GRANT</b> { ALL | statement [ ,...n ] } <br />
TO security_account [ ,...n ]</td>
<td width="71%" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="8" valign="top">
对象权限:<br />
<b>GRANT</b><br />
{ ALL [ PRIVILEGES ] | permission [ ,...n ] }<br />
{ [ ( column [ ,...n ] ) ] <br />
ON { table | view } | ON { table | view } [ ( column [ ,...n
] ) ]| <br />
ON { stored_procedure | extended_procedure }| ON { user_defined_function
}} <br />
TO security_account [ ,...n ] [ WITH GRANT OPTION ] [ AS
{ group | role } ]</td>
</tr>
<tr>
<td width="97%" colspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="4" valign="top">
示例</td>
</tr>
<tr>
<td width="97%" colspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="3" valign="top">
grant insert,select,update,delete on table1 to public
</td>
</tr>
</table>
<hr color="#003366" size="1" />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="166">
<tr>
<td width="100%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
六、 删除以前在当前数据库内的用户上授予或拒绝的权限。</td>
</tr>
<tr>
<td width="3%" rowspan="4" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="151">
</td>
<td width="97%" colspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
语法</td>
</tr>
<tr>
<td width="26%" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="8" valign="top">
语句权限:<br />
<b>REVOKE</b> { ALL | statement [ ,...n ] } <br />
FROM security_account [ ,...n ]</td>
<td width="71%" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="8" valign="top">
对象权限:<br />
<b>REVOKE</b> [ GRANT OPTION FOR ] { ALL
[ PRIVILEGES ] | permission [ ,...n ] }<br />
{ [ ( column [ ,...n ] ) ] <br />
ON { table | view }| ON { table | view } [ ( column
[ ,...n ] ) ]<br />
| ON { stored_procedure | extended_procedure }| ON {
user_defined_function }} <br />
{ TO | FROM } security_account [ ,...n ] <br />
[ CASCADE ] [ AS { group | role } ] </td>
</tr>
<tr>
<td width="97%" colspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="4" valign="top">
示例</td>
</tr>
<tr>
<td width="97%" colspan="2" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="3" valign="top">
revoke insert,delete on table1 from public </td>
</tr>
</table>
<hr color="#003366" size="1" />
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="166">
<tr>
<td width="100%" colspan="4" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="15">
七、添加或更改 Microsoft SQL Server 登录的密码。</td>
</tr>
<tr>
<td width="3%" rowspan="5" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="151">
</td>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="30">
语法<br />
<b>sp_password</b> [ [ @old = ] 'old_password' ,
] { [ @new =] 'new_password' }
[ , [ @loginame = ] 'login' ]</td>
</tr>
<tr>
<td width="97%" colspan="3" style="font-family: 宋体; font-size: 9pt; color: #003366; line-height: 150%" height="17">
参数</td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -