如何建立LocalDB資料庫和資料庫執行個體

來源:互聯網
上載者:User

如何建立LocalDB資料庫和資料庫執行個體

LocalDB是SQL Server 2012帶來的新特性,它是一個專門為開發人員量身定製的輕量級資料庫,下面介紹如何使用它。

建立LocalDB資料庫的方法:

開啟伺服器總管,右鍵點擊“資料連線”建立新Sql Server資料庫,伺服器名填寫:(LocalDB)\v11.0,表示串連到v11.0執行個體。

建立一個新的資料庫名為“Work”,然後點擊“確定”按鈕,完成建立資料庫操作。

在項目中的設定檔中修改資料庫連接字串。

<connectionStrings>
    <add name="WorkDatabase" connectionString="Data Source=(localDB)\v11.0;Initial Catalog=Work;Integrated Security=True;"/>
  </connectionStrings>


還可以通過SqlLocalDB.exe工具建立資料庫執行個體。

這個程式一般位於以下路徑:C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe

建立Test資料庫執行個體:

SqlLocalDB.exe create Test

啟動Test資料庫執行個體:

SqlLocalDB.exe start Test

停止Test資料庫執行個體:

SqlLocalDB.exe stop Test

顯示Test資料庫執行個體資訊:

SqlLocalDB.exe info Test

顯示所有資料庫執行個體資訊:

SqlLocalDB.exe info

本文永久更新連結地址:

相關文章

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.