sql server localdbver有多个localdb

当前位置: >
SQL Server LocalDB数据库管理之旅
伴随着SQL Server 2012的发布,SQL Server LocalDB跃入我们的眼帘。。
SQL Server LocalDB能够最大限度地节省您的数据库管理精力,以便开发人员可以专注于开发数据库应用。
使用SqlLocalDB命令行管理LocalDB
为了方便管理,LocalDB提供了一个基于命令行的数据库管理工具SqlLocalDB.exe。下面是SqlLocalDB.exe的路径:
%ProgramFiles%\Microsoft&SQL&Server\110\Tools\Binn&
我们可以在Windows操作系统的CMD命令行中运行SqlLocalDB.exe:
Cd&%ProgramFiles%\Microsoft&SQL&Server\110\Tools\Binn &
SqlLocalDB.exe&/?&
图1:SqlLocalDB -?
SqlLocalDB以空格作为分隔符,因此,如果实例名中包含空格或其它特殊字符,我们引用的时候需要加引号。例如:
SqlLocalDB&create&&My&LocalDB&Instance&&
管理员或开发人员可以使用create选项创建LocalDB实例,使用-s选项,将会在实例创建之后启动实例。例如:
SqlLocalDB&create&&MyLocalDB&&11.0&-s&
可以使用如下命令查看MyLocalDB实例的状态信息:
SqlLocalDB&info&&MyLocalDB&&
该命令将返回如下信息:
图二:SqlLocalDB info MyLocalDB
启动、停止LocalDB实例:
SqlLocalDB&start&&MyLocalDB& &
SqlLocalDB&stop&&MyLocalDB&&
删除LocalDB实例:
SqlLocalDB&delete&&MyLocalDB&&
以上使用SqlLocalDB.exe命令行实用工具管理LocalDB的一点简要总结,更多功能还有待于读者自己去挖掘,记得用SqlLocalDB.exe /?命令寻求帮助。
使用SQL Server Management Studio(SSMS)管理LocalDB
读到这里,大家是否有灵感闪现,找到了一种用SQL Server Management Studio(SSMS)管理LocalDB的方法?没错,就是利用&实例管道名称&!
首先,我们仔细观察上面的LocalDB实例信息,注意&实例命名管道名称&一项。
然后,在SQL Server Management Studio(SSMS)中点击&连接&|&数据库实例&,在&服务器名称&中输入&实例管道名称&,如图所示:
图3:连接到服务器
最后,选择&Windows身份验证&,点击&连接&:
图4:SQL Server Management Stdio
祝您的数据库之旅愉快!如果有问题,请在评论中与我分享。
(责任编辑:蒙遗善)java.sql.SQLException:No suitable driver found for jdbc.sqlserver://localhost:1433;DatabaseName=AS_百度知道
java.sql.SQLException:No suitable driver found for jdbc.sqlserver://localhost:1433;DatabaseName=AS
com/zhidao/wh%3D600%2C800/sign=f0cbf84c7f91e903e4ad/dcd109a5dccbf6c814d26://g;jdbc://g.jpg" esrc=";;DatabaseName=AS&quot!&quot..com/zhidao/wh%3D450%2C600/sign=54a154efca95d143da23ec/dcd109a5dccbf6c814d26;
Class.123456&quot.jpg" />连接SQL Sever2008测试代码import java.out.hiphotos://g.
String userPwd =&quot.*;}
} }sqljdbc4.microsoft.
/zhidao/pic/item/dcd109a5dccbf6c814d26;public class test { public static void main(String[] args){
String driverName=&quot.baidu.com.jpg" target="_blank" title="点击查看大图" class="ikqb_img_alink"><img class="ikqb_img" src="
String dbURL=&.printStackTrace();
Connection dbC
String userName=&quot.baidu.forName(driverName),userPwd)://sa&quot.getConnection(dbURL.}
catch(Exception e){e.jar已经引入仍然显示错误.jdbc.SQLServerDriver&Connection Successful:1433;),userN
System.println(&quot<a href="http
提问者采纳
当只用【sqljdbc4,需要三个jar包。正确的做法是删掉【sqljdbc,&quot:1433;;databasename=spdb&quot【1】我也遇到过同样的问题。【3】我用的是相当高的jdk7:sqlserver.jar】包.jar】.jar】包时;localhost。Tomcat就会出现驱动不匹配的提示。【2】以前的jdk的版本较低;此处填写你的sa对应的密码&quot.getConnection(&quot:&#47,当时下载了两个jar包【jdbc,代码
Connection conn=DriverManager。试试看行不行;WEB_INF&#92;);。有的话就不能成功连接,只留一个【sqljdbc4;Test&#92。【4】注意。当我把这 两个包【同时】放到【Tomcat&#92.jar】;那个jdbc和sqlserver之间【没有】/sa&quot.jar】包;lib】(Test是我自己起的名字)目录下时,&quot。系统却会默认调用【sqljdbc.0;lib】目录和【webapps&#92.jar】和【sqljdbc4
我也用的jdk7,但是没有用Tomcat和webapps,必须得下载这两个么
那你的是java项目么?如果是java项目你导入的包构建了么,构建好后原始的包不能删除,如果删除了就没发找到了,还有像问问你的数据库名称、密码、数据库名那些有木有输错我又仔细看了你贴的那段代码发现有个问题,如下:String dbURL=&jdbc.sqlserver:&#47;&#47;localhost:1433;DatabaseName=AS&;改为下面的代码:String dbURL=&jdbc:sqlserver:&#47;&#47;localhost:1433;DatabaseName=AS&;你试试看~~~~~~~~~~~~··
提问者评价
O(∩_∩)O谢谢
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Stack Overflow is a question and answer site for professional and enthusiast programmers. It&#39;s 100% free, no registration required.
I'm following
tutorial and noticed that it suggested to connect to (localdb)\v11.0 in learning purposes. I've tried to connect to it using my SQL Management Studio and it worked. But when I've restored a DB backup it created an [DatabaseName].mdf file in my user's directory.
I'm quite surprised and have following questions:
What is a (localdb)\v11.0? Does it uses my SQL Express or SQL Compact?
Does it support only databases stored in .mdf files?
How can I specify path for my restore other than my user's folder?
What general purposes does it serve (is it for learning purposes only)?
Where can I find more info about this kind of database?
LocalDB was introduced in SQL Server 2012 CTP3. It’s basically a new version of SQL Express, with same functionality, dedicated to developers. So you don’t need to install any SQL server. If you have installed SQL 2012 or Visual Studio 11 then you already have it, and it runs over .Net 4 or higher. If you are using Visual Studio 11 and have been playing with the new EntityFramework and MVC, you can see it on the default connection string. ()
MDF is the default extension for SQL Server database files. (Log files are LDF) Also see .
You can restore to a specific folder by using RESTORE DATABASE WITH MOVE as documented on MSDN .
LocalDB is intended for developers, see point 1.
The SQL Server Express blog has an informative post about LocalDB .
23.8k1273119
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledIntroducing LocalDB, an improved SQL Express - SQL Server Express WebLog - Site Home - MSDN Blogs
Powered by
Introducing LocalDB, an improved SQL Express
Introducing LocalDB, an improved SQL Express
Updated : Added reference to the walkthrough of
and to the new .
Updated : Added reference to
in the Q&A section.
Introduction
It gives me great pleasure to introduce a new version of SQL Express called SQL Express LocalDB.
LocalDB is created specifically for developers. It is very easy to install and requires no management, yet it offers the same T-SQL language, programming surface and client-side providers as the regular SQL Server Express. In effect the developers that target SQL Server no longer have to install and manage a full instance of SQL Server Express on their laptops and other development machines. Moreover, if the simplicity (and limitations) of LocalDB fit the needs of the target application environment, developers can continue using it in production, as LocalDB makes a pretty good embedded database too.
Background
Before focusing on technical description of LocalDB, I'd like to provide some background on the direction we took building it.
Today SQL Server Express serves two distinct needs. On one hand it is a free edition of SQL Server. The installation, management and programming of SQL Express in this role is expected to be 100% compatible with other editions. It can be used for learning, training and to run relatively small production database (with less than 10GB of data). Upgrade from SQL Express to paid SQL Server editions is a matter of typing in a license key and no installation is required.
But SQL Express is also SQL Server edition for developers writing applications targeting SQL Server. In this role the programming of SQL Express is still expected to be 100% compatible with other SQL Server editions, but SQL Express is supposed to be small, simple, low-footprint, require no configuration or administration, run as non-admin user, etc.
Our approach so far was to try to make SQL Express perform well in both roles. But as SQL Server product matured, and in effect added more complexity, it became harder and harder for SQL Express to be both compatible with other SQL Server editions and small/simple. The challenge is most visible in installation and configuration of SQL Express. In SQL Server "Denali" we decided to change the approach it and introduce a dedicated version of SQL Express for developers - LocalDB that delivers the simplicity and yet is compatible with other editions of SQL Server at the API level.
Also, by making LocalDB a better SQL Express for developers, we hope to be able to improve the regular SQL Express to be a better free SQL Server. We'd be very happy to hear your feedback in this area, especially if you're using SQL Express as a database server and find any issues caused by the new features that were introduced to fit the needs of developers and desktop environment.
High-Level Overview
After the lengthy introduction it's time to take a look at LocalDB from the technical side. At a very high level, LocalDB has the following key properties:
LocalDB uses the same sqlservr.exe as the regular SQL Express and other editions of SQL Server. The application is using the same client-side providers (ADO.NET, ODBC, PDO and others) to connect to it and operates on data using the same T-SQL language as provided by SQL Express.
LocalDB is installed once on a machine (per major SQL Server version). Multiple applications can start multiple LocalDB processes, but they are all started from the same sqlservr.exe executable file from the same disk location.
LocalDB doesn't create a LocalDB processes are started and stopped automatically when needed. The application is just connecting to "Data Source=(localdb)\v11.0" and LocalDB process is started as a child process of the application. A few minutes after the last connection to this process is closed the process shuts down.
LocalDB connections support AttachDbFileName property, which allows developers to specify a database file location. LocalDB will attach the specified database file and the connection will be made to it.
LocalDB Instances
As we said before, at the heart of LocalDB is the same sqlservr.exe as in the regular SQL Express and other editions of SQL Server. In case of LocalDB, it is installed into one central location together with all necessary DLLs. By default it is located at "C:\Program Files\Microsoft SQL Server\110\LocalDB\Binn".
When an application uses any of the client-side providers (like ADO.NET, ODBC or PDO) to connect to "Data Source=(localdb)\v11.0", the provider will first check if LocalDB instance for the current user is started. If it's already started the application will connect to it. Otherwise the LocalDB instance for the current user will be started and then the provider proceeds to connect to it. Note that each user (Windows login) may have their own LocalDB instance that is isolated from instances of other users.
To try LocalDB just use this connection string: "Data Source=(localdb)\v11.0;Integrated Security=true". Note that because the activation logic lives in the client-side provider, you need to install the latest one - SQL Server Native Client "Denali" (for ODBC and OLE DB) or the next .NET Framework (for ADO.NET). We are also shipping a QFE for .NET Framework 4 that adds the support for LocalDB to it (the updated .NET Framework 4 is already available, see
for details).
Database as a File
LocalDB connection strings support AttachDbFileName property that allows attaching a database file during the connection process. This lets developers work directly with databases instead of the database server. Assuming a database file (*.MDF file with the corresponding *.LDF file) is stored at "C:\MyData\Database1.mdf" the developer can start working with it by simply using the following connection string: "Data Source=(localdb)\v11.0;Integrated Security=AttachDbFileName=C:\MyData\Database1.mdf".
New Installer
In this CTP LocalDB is a shared feature of SQL Server Express available to try as an option during installation of any other version of SQL Express. Our ultimate goal is to offer LocalDB in a separate, simplified and smaller installer. We will keep you posted on our progress here.
LocalDB and User Instances of SQL Express
Users familiar with today's User Instances of SQL Server Express should feel right at home with LocalDB. In essence LocalDB offers the ability to create and start a "user instance" without the hassle of installing and maintaining the parent SQL Express instance. In that respect LocalDB could be seen as an upgrade of the User Instances feature of SQL Server Express.
Let me also take this opportunity to remind everyone that User Instances are on a deprecation path since SQL Server 2008.
LocalDB and SQL Express
LocalDB is not a replacement for SQL Server Express -- it is an addition to SQL Server Express lineup. While LocalDB is meant for developers, the regular SQL Server Express will continue to exist as a free SQL Server edition, fully compatible with and easily upgradeable to higher SQL Server editions.
LocalDB and SQL Server Compact?
Small and simple database, lightweight installation, connecting to a database file -- this will sound familiar to any developer using SQL Server Compact. The similarities are not accidental, as our goal for LocalDB was to be as easy to use as SQL Server Compact (while being as powerful and compatible with full SQL Server as SQL Express).
There are significant differences between LocalDB and SQL Server Compact:
Execution mode: SQL Server Compact is an in-proc DLL, while LocalDB runs as a separate process.
Disk usage: all SQL Server Compact binaries amount to some 4MBs, while LocalDB installation takes 140MBs.
Features: SQL Server Compact offers core RDBMS functionality like querying, while LocalDB provides a much richer set of features, including Stored Procedures, Geometry and Geography data types, etc.
Send us Your Feedback
Please share your feedback with us! Feel free to start a thread on , hit the "Email Author" button on this post or file a
Thank you all for your feedback. Please read below for answers to your questions!
Q: You say that LocalDB runs as a separate process. However, the main SQL Server site states "LocalDB has all of the same programmability features as SQL Express, but runs in-process with applications". So which is it?
A: LocalDB runs as a separate process - it does not run in-process. It does&however run in the same security context as the calling application.
Q: Does SQL Express Denali still have the same memory limitations as that of SQL Server 2005 Express.
A: The memory limitation has not changed for Denali. At Denali RTM, LocalDB will have the same memory limitations as Express.
Q: What is the difference between LocalDB and SQL Server Compact Edition?
A: LocalDB is&the SQL Server database engine. As such it offers functionality&such as&online backup, transactions and data integrity.& LocalDB is designed for PCs but unlike Compact does not support small mobile devices like smart phones because of its hardware and disk requirements. Compact Edition is a shared file system database.& It is not fully API compatible with SQL Server and does not support the same level of data integrity. SQL Compact is also not supported by the PHP Driver and PDO.
Q: Where can I find the option to install LocalDB?
A: You must install the SQL Server Express Edition and select LocalDB as a feature. You can unselect the Database Engine if you do not require SQL Server Express as a service.
A: Starting from SQL Server 2012 RC0 LocalDB can be downloaded and installed separately, as described in .
Q: How do you actually create a LocalDB database?
A: Connect to LocalDB and then use the usual T-SQL &CREATE DATABASE && command.
Q: Can LocalDB be a subscriber for merge replication?
A: Merge replication is not supported by LocalDB.
Q: Can LocalDB be launched from a service?
A: LocalDB can be launched from a service, as long as the profile is loaded for the service account.
Q: Installed OK, but how about a nice little VS2010 C# (working) sample for creating a LocalDB database?
A: We are currently working on a sample application to illustrate the usage of LocalDB in C#.
A: Please see
for a sample walkthrough.
Q: When will System.Data.SqlClient support LocalDB?
A: LocalDB is planned to be supported with .NET 4.0 with a QFE (not yet shipped) and future versions of .NET
A: LocalDB is supported by System.Data.SqlClient in .NET Framework 4 Update 4.0.2, as announced in .
Leave a Comment
An error occurred while posting! Please retry posting your comment.}

我要回帖

更多关于 localdb 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信