In SQL Server 2008, in order to protect the security of the database, the need to different users to open different access users, then how to simply control the user's permissions? Below we will create a read-only user, for everyone to learn to use.
One, the command line method to create
Create a new Query window, then enter the following command and then execute it.
sqlserver command method to increase the login name, user name and give appropriate permissions
sp_addlogin ' test ', ' test ', ' db ' >> login name, password, login database
sp_grantdbaccess ' test ' >> Adding a database user to the current database
Grant Select/update/delete on tablea/viewb to test >> gives the user permission to query/update/delete table TABLEA Or trying to viewb the permissions
Second, the traditional software window creation
Microsoft SQL Server Management Studio
Method/Step
First open Microsoft SQL Server Management Studio and log in with the administrator account. Here I choose the server is "local", the account is "Windows Authentication", if it is connected to a remote server, enter the remote server address.
1. Enter SQL Server Management Studio
2. Select Security, login name, right-click New Login
3, enter the user name and password in the general
4. In "User mapping", "users mapped to this login" select the database that the user can manipulate
5. In "Database role membership", select "Public" and "db_datareader",
6, such a read-only user is created to complete.
Knowledge Reference Server role reference (can operate on a database)
Bulkadmin can run BULK INSERT statement BULK INSERT verbose http://blog.csdn.net/jackmacro/article/details/5959321
dbcreator Create, modify, delete, restore any database
Diskadmin managing disk files
Processadmin can terminate a program that runs in an instance of the database engine
securityadmin can manage logins and their properties, have Grant,deny, and revoke server and database-level permissions, and can reset passwords for SQL Server logins
ServerAdmin can change server-wide configuration options and shut down the server
Setupadmin can add and remove linked servers and execute stored procedures (such as sp_serveroption) on certain systems that can execute
The sysadmin makes any activity in SQL Server that feels that the permissions span all other fixed server roles, and by default, all members of the Windows Builtin\admin Group (local Administrators group) are the sysadmin /c2> member of fixed server role
User Mapping Reference (can operate on database data)
DB_Owner users who can perform all the technical actions in the database
Db_accessadmin can add, delete user's user
Db_datareader can view data from user tables in all databases
Db_datawrite can add, modify, and delete data from all database user tables
db_ddladmin user that can perform DDL operations in the database,creation of DDL (Data Definition Language) tables, and management
Db_securityadmin can manage users in the database for all actions related to security permissions
Db_backoperator users who can back up the database (DBCC and CHECKPOINT statements can be published, which are typically used before the backup
Db_denydatareader Users who cannot see any data in the database
Db_denydatawrite Users who cannot modify any data in the database
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Two ways to create user-only read-only permissions for a SQL Server 2008 database