SqlLocalDB工具的一些有趣发现

本文只是记录个人使用SqlLocalDB过程中的一些有趣现象,并不一定适用所有情况。关于SqlLocalDB的简介及相应命令行工具的具体使用,参见: SQL Server LocalDB 入门SqlLocalDB Utility

  1. 当本地安装多个版本的SQL Server LocalDB时,无法创建低版本的名为MSSQLLocalDB的默认实例(注: LocalDB的第一个版本是SQL Server 2012, 默认实例名是v11.0, 从SQL Server 2014开始,默认实例名修改成了MSSQLLocalDB), 也无法通过指定Version创建该默认实例。但是不指定Version或者通过SSMS连接(localdb)\MSSQLLocalDB却可以创建该实例。
    C:\>SqlLocalDB versions
    Microsoft SQL Server 2016 (13.1.4001.0)
    Microsoft SQL Server 2017 (14.0.1000.169)
    
    C:\>SqlLocalDB info
    MSSQLLocalDB
    ProjectsV13
    
    C:\>SqlLocalDB delete MSSQLLocalDB
    Delete of LocalDB instance "MSSQLLocalDB" failed because of the following error:
    The specified LocalDB instance does not exist.
    
    C:\>SqlLocalDB create MSSQLLocalDB 13.1
    Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error:
    The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation.
    
    C:\>SqlLocalDB create MSSQLLocalDB 13.1.4001.0
    Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error:
    The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation.
    
    C:\>SqlLocalDB create MSSQLLocalDB 14.0
    Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error:
    The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation.
    
    C:\>SqlLocalDB create MSSQLLocalDB 14.0.1000.169
    Creation of LocalDB instance "MSSQLLocalDB" failed because of the following error:
    The parameter for the LocalDB Instance API method is incorrect. Consult the API documentation.
    
    C:\>SqlLocalDB create MSSQLLocalDB
    LocalDB instance "MSSQLLocalDB" created with version 14.0.1000.169.
    
  2. 虽然安装了多个版本的SQL Server LocalDB, 但是却不能创建同名实例,试着创建同名实例,返回消息也不一样。
    C:\>SqlLocalDB create MyDataBase 13.1
    LocalDB instance "MyDataBase" created with version 13.1.4001.0.
    
    C:\>SqlLocalDB create MyDataBase 14.0
    Creation of LocalDB instance "MyDataBase" failed because of the following error:
    Unable to create the LocalDB instance with specified version. An instance with the same name already exists, but it has lower version than the specified version.
    
    C:\>SqlLocalDB create MySQLDB
    LocalDB instance "MySQLDB" created with version 14.0.1000.169.
    
    C:\>SqlLocalDB create MySQLDB 13.1.4001.0
    LocalDB instance "MySQLDB" created with version 14.0.1000.169.
    
    C:\>SqlLocalDB info
    MSSQLLocalDB
    MyDataBase
    MySQLDB
    ProjectsV13
    
    C:\>SqlLocalDB info MyDataBase
    Name:               MyDataBase
    Version:            13.1.4001.0
    Shared name:
    Owner:              XXXXXXXXXX
    Auto-create:        No
    State:              Stopped
    Last start time:    2020/8/23 11:14:50
    Instance pipe name:
    
    C:\>SqlLocalDB info MySQLDB
    Name:               MySQLDB
    Version:            14.0.1000.169
    Shared name:
    Owner:              XXXXXXXXXX
    Auto-create:        No
    State:              Stopped
    Last start time:    2020/8/23 11:15:42
    Instance pipe name:
    
  3. 无意中发现,原来CMD也支持管道,好吧, 认知再一次被刷新(另: 默认实例MSSQLLocalDBAuto-create属性是Yes, 其他的是No)!
    C:\>SqlLocalDB info MSSQLLocalDB | sort
    Auto-create:        Yes
    Instance pipe name:
    Last start time:    2020/8/23 10:56:20
    Name:               MSSQLLocalDB
    Owner:              XXXXXXXXXX
    Shared name:
    State:              Stopped
    Version:            14.0.1000.169
    
    C:\>SqlLocalDB info | sort
    MSSQLLocalDB
    MyDataBase
    MySQLDB
    ProjectsV13
    
posted @ 2020-08-23 11:46  天琊蓝  阅读(344)  评论(0编辑  收藏  举报