zoukankan      html  css  js  c++  java
  • Microsoft SQL Server 2012 管理 (2): 实例与数据库管理

    1.加密数据库

    /*
    Module 2 Implementing Transparent Data Encryption
    */
    
    -- 2.1 Create DataBase Master Key
    USE Master;
    GO
    
    Create Master Key Encryption By Password='SuperKey@currentMachine'
    -- The password above must adhere to the windows password policy
    -- could also use a hardware encryption module.
    
    -- 2.2 Create a Srever Certificate Derived from Database Master Key
    USE master;
    GO
    
    Create Certificate TDE_Cert with subject='TDE_Encryption_Cert'
    
    -- 2.3 Create Database Encryption key for a User Database
    USE TinyDB
    GO
    
    Create Database Encryption Key with Algorithm=AES_256
    Encryption by Server Certificate TDE_Cert
    -- The are other algorithm choices but AES_256 is the STRONGEST
    
    -- 2.4 Protect User Database
    USE TinyDB
    GO
    
    Alter Database TinyDB
    Set ENCRYPTION ON
    
    -- 2.5 FollowUp
    /*
    Back up all keys in the hierarchy to a safe place
    In practice TEST moving/restoring the database to another instance.
    */

     2. 压缩数据

    /*
    Implementing Data Compression
    */
    
    Create Database DBWithRedundantData
    GO
    
    USE DBWithRedundantData
    GO
    
    --Create a Table Assigning Row Compression
    
    Create Table GreatForRowCompression
    (
    Col1 int
    ,Col2 char(5)
    ,Col3 char(3)
    ,Col4 char(2)
    ) WITH (DATA_Compression=ROW)
    
    --Create a Table Assigning Page Compression
    
    Create Table GreatForPageCompression
    (
    Col1 int
    ,Col2 char(5)
    ,Col3 char(3)
    ,Col4 char(2)
    ) WITH (DATA_Compression=PAGE)
    
    /*
    Keep in mind ALTER TABLE and ALTER INDEX can be used 
    to implement compression when those obects already exist.
    */

    3. 数据库可用性

    /*
    Change various database option and refresh the Mgmt
    */
    
    -- 2.1 Setup: Add a Table and a couple of rows.
    USE TinyDB;
    GO
    
    Create Table dbo.T1 (Col1 int Identity, COl2 Varchar(20) default 'T1')
    Insert T1 default values
    GO 5
    
    -- 2.2 Chnage Avalablity options
    Alter database TinyDB
        Set OFFLINE
        -- The Database is Absolutely inaccessible
        --Cleanly shus down the database without having to DETACH
        --Refresh the Databasees node in Mgmt Studio to notice the change
    
        --Try this query to see what happens... Select * from T1
    
    Alter database TinyDB
        Set EMERGENCY
        -- limited access (Only SysAdmins). This might be useful for 
        -- Transaction Log repairs with DBCC.
            --Try this query to see what happens... Select * from T1
    
    Alter database TinyDB
        Set ONLINE -- The Default Option
    
    Alter database TinyDB
        Set READ_ONLY
        -- Cannot make changes to the database
    
        -- Try this query to see what happens... UPDATA T1 set Col2='dd' where Col1=1
    
    Alter database TinyDB
        Set READ_WRITE -- the Default Option
    
    Alter database TinyDB
        Set SINGLE_USER
        -- Only one authoritative user can connect to the database
        -- Userd when DBCC CheckD repair_allow_data_loss is used
    
    Alter database TinyDB
        Set RESTRICTED_USER
    
    Alter database TinyDB
        Set MULTI_USER -- the Default Option
  • 相关阅读:
    结构体初始化所遇到的问题
    字符串赋值注意事项
    C语言可变参数 "..."
    typedef 定义指针数组和数组指针及其使用。
    指针函数、指针数组、函数指针、数组指针、函数指针数组。
    前端回血day24 flex子项伤的CSS属性
    Fiddler使用
    一句话“截流”和“防抖”
    django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.
    Linux
  • 原文地址:https://www.cnblogs.com/yanyan45/p/3948502.html
Copyright © 2011-2022 走看看