在SQL Azure中如何创建只读用户 [英] In SQL Azure how can I create a read only user

查看:117
本文介绍了在SQL Azure中如何创建只读用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个SQL Azure用户并授予她对几个数据库的只读访问权限,我可以使用什么脚本来实现此目的?

I would like to create an SQL Azure user and grant her read-only access on a handful of DBs, what script can I use to achieve this?

推荐答案

纯TSQL脚本太乱了,SQL Azure禁用了USE命令,因此您被困在打开与每个DB的连接上,需要让用户读取使用权.

A pure TSQL script is super messy, SQL Azure disables the USE command, so you are stuck opening connections to each DB you need to give the user read access.

这是模式的要旨.

在主数据库中:

CREATE LOGIN reader WITH password='YourPWD';
-- grant public master access
CREATE USER readerUser FROM LOGIN reader;

在每个目标数据库中(需要单独的连接)

In each target DB (requires a separate connection)

CREATE USER readerUser FROM LOGIN reader;
EXEC sp_addrolemember 'db_datareader', 'readerUser';

这篇关于在SQL Azure中如何创建只读用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆