我在数据库中有SQL Server用户,出于某种原因,用户在连接时无法查看表
以下是我用来创建该用户的命令。我不想让用户dbuser
成为架构的所有者。
create user dbuser for login dbuser'
--on the specific database, I am using these commands.
exec sp_addrolemember @rolename = 'db_datareader', @membername = 'dbuser'
exec sp_addrolemember @rolename = 'db_datawriter', @membername = 'dbuser'
grant select on schema :: [schema1] TO [dbuser]
grant insert on schema :: [schema1] TO [dbuser]
grant update on schema :: [schema1] TO [dbuser]
grant execute on schema :: [schema1] TO [dbuser]
grant select on schema :: [schema2] TO [dbuser]
grant insert on schema :: [schema2] TO [dbuser]
grant update on schema :: [schema2] TO [dbuser]
grant execute on schema :: [schema2] TO [dbuser]
即使我在模式上授予所有插入和更新访问权限,但用户在使用dbuser
登录时无法查看任何模式中的任何表。当用户尝试连接到数据库时,他只看到系统表选项卡。用户需要查看schema1,schema2, schema3
感谢
答案 0 :(得分:1)
您确定用户是连接到您的数据库而不是主数据库吗?而你是在正确的数据库中创建用户?
答案 1 :(得分:1)
答案 2 :(得分:1)
扩展上述答案。
GRANT VIEW DEFINITION ON SCHEMA::[schema1] TO [dbuser];
GRANT VIEW DEFINITION ON SCHEMA::[schema2] TO [dbuser];