SQL Server Database Security

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/hoojo/archive/2011/07/20/2111990.html

--Create a login user
--create login login_name from windows with Default_database = Database | Default_language = language;
Create login [localhost\hoojo-pc] from windows with default_database = Testhome;
--Create a login user
--create login login_name with password = ' pwd ' [hashed] [Must_change] [check_expiration] [Check_policy]
Create login admin with password = ' 123456 ', default_database = Testhome;

--View Login user
SELECT * from Sys.sql_logins;

--Modify User
ALTER LOGIN admin with name = Jackson;
ALTER LOGIN to jackson with password = ' ABCD ';

--Disable, enable user
ALTER LOGIN to Jackson disable; --Disable
ALTER LOGIN to Jackson enable; --Enable

--Delete User
Drop Login to Jackson;

--Modify the mapping credentials (map login Macraes to credential Custodian04)
ALTER login Jackson with credential = Custodian04;

-------Database User
--Create a database user
Create user jack from login admin;
Create user Jason for login Jackson;

Create user jack from the login admin with default_schema = Temp_schema;

--Start the guest user (not recommended)
--Special user dbo, guest;sa corresponding dbo user, other users not mapped is the guest user
Grant connect to Guest;

--Modify User
Alter user jack with name = Jason;
Alter user Jason with default_schema = Jason_schema;

--Delete User
Drop user Jason;

--------Database Roles
--Empowering Jack users to buyers roles
Create role buyers authorIzation Jack;

--Modifying roles
Alter role buyers with NAME = New_buyers;

--Remove roles
Drop role new_buyers;

--------Architecture Management
--Create
Create schema Temp_schema;

--Specify user
Create schema Jason_scheam authorization Jason;

--Authorization inquiry
Grant Select to Jason;

--Delete
Drop schema Jason_scheam;

--------Permissions
--Authorization to create table
Grant CREATE table to Jason;
--Authorize Jason to inquire student form
Grant SELECT on student to Jason;

--Revoke permissions
Revoke CREATE table to Jason;
Revoke select on student to Jason;

SQL Server Database Security

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.