SqlLocalDB 的一些經常使用命令行

Once installed, you can interact with SqlLocalDb using the command line. The following will tell you the version of SqlLocalDb:數據庫

C:\> SqlLocalDb info

Result:this

v11.0

If you want to create an instance:spa

C:\> SqlLocalDb create "MyInstance"

Result:code

LocalDB instance "MyInstance" created with version 11.0.

To start the instance:orm

C:\> SqlLocalDb start "MyInstance"

Result:ci

LocalDB instance "MyInstance" started.

You can also create an instance and start it in one command using the -s argument:字符串

C:\> SqlLocalDb create "MyInstance" -s

To stop and delete an instance, you can issue two commands:get

C:\> SqlLocalDb stop   "MyInstance"
C:\> SqlLocalDb delete "MyInstance"

If you try to just delete the instance without first stopping it, you will get this error:it

Delete of LocalDB instance "MyInstance" failed because of the following error:
Requested operation on LocalDB instance cannot be performed because specified instance is currently in use. 
Stop the instance and try again.

To check on the status and other details about an instance, you can run:io

C:\> SqlLocalDb info "MyInstance"


當 "MyInstance" 創建後就可使用鏈接字符串:Data Source=(LocalDb)\PRJS;Initial Catalog=PCDT;Integrated Security=SSPI;AttachDBFilename=E:\prjs\PCDT\db\PCDT.mdf
來鏈接這個數據庫實例。注意,最好不要使用默認的 v11.0 實例,PRJS 爲新建的實例。
相關文章
相關標籤/搜索