SQL Server:本机客户端与 ODBC?
SQL Server Native Client 连接和 ODBC 连接有什么区别?这两者有何优缺点?
What is the difference between SQL Server Native Client connection and ODBC connection? What are the pros and cons of these two?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
啊? ODBC 正式消亡了吗?有人可能想让 Microsoft 知道:
Microsoft 正在与 ODBC 保持一致以进行本机关系数据访问
从上面的链接:
并且
最后,
(强调)
Huh? ODBC is officially dead? Someone might want to let Microsoft know that:
Microsoft is Aligning with ODBC for Native Relational Data Access
From the above link:
and
and finally,
(emphasis added)
当底层数据库可能发生变化但您不希望代码发生变化(假设 SQL 在各种技术中保持不变)时,ODBC 非常有用。您可以有一天连接到 Oracle 数据库,第二天切换到 SQL Server 数据库。缺点是您无法获得特定驱动程序所提供的优化。 SQL Server Native 客户端驱动程序已被证明比仅使用标准 ODBC 驱动程序要快得多。
ODBC is useful for times when the underlying database might change but you don't want your code to (assuming the SQL stays the same across technologies). You could connect to an Oracle database one day and switch out to a SQL server database the next. The disadvantage is that you don't get the optimizations that having specific drivers affords you. The SQL Server Native client driver has been proven to be much faster than just using a standard ODBC driver.
ODBC 是一个标准化的 API。
ODBC 驱动程序是使用本机协议(例如 SQL Server 共享内存或 SQL Server TCP/IP)来实现 ODBC 接口的共享库。
换句话说,ODBC 是一种抽象,它使代码能够针对多种数据库技术工作。
它类似于Java的JDBC,或Python的DB-API,或GO的database/sql,只不过ODBC驱动程序使用C函数。此外,它们更频繁地安装在系统级别。
ODBC 具有任何抽象的常见优点和缺点。
优点:使代码更加灵活/可移植。
缺点:增加性能开销并且功能较少。
听起来您知道您将使用 SQL Server 并且将始终使用 SQL Server。
在这种情况下,我会使用本机客户端库(如果可用)。
ODBC is a standardized API.
ODBC drivers are shared libraries that use native protocols (like SQL Server shared memory, or SQL Server TCP/IP) to implement the ODBC interface.
In other words, ODBC is an abstraction that enables code to work against multiple database technologies.
It's similar to Java's JDBC, or Python's DB-API, or GO's database/sql, except ODBC drivers use C functions. Also, they are more frequently installed at a system level.
ODBC has the usual pros and cons of any abstraction.
Pros: Makes code more flexible/portable.
Cons: Adds performance overhead and has fewer features.
It sounds like you know that you will use SQL Server and will always use SQL Server.
In that case, I'd use a native client library if it's available.
SQL Server Native Client 是一个动态链接库 (DLL),其中包含适用于 Windows 的 SQL OLE DB 提供程序和 SQL ODBC 驱动程序。
https://blogs.msdn.microsoft.com/sqlreleaseservices/snac-lifecycle -解释/
SQL Server Native Client is a single dynamic-link library (DLL) containing both the SQL OLE DB provider and SQL ODBC driver for Windows.
https://blogs.msdn.microsoft.com/sqlreleaseservices/snac-lifecycle-explained/