对于这个问题的背景,
请参阅“如何序列化大型
.NET 对象到 SQL Server 的图表
无需创建大的 BLOB
缓冲区?” 现在有一个很大的
赏金。
SqlFileStream 为您提供IoStream 位于 blob 顶部 (varbinary) 存储在数据库中的值。然而,由于 SqlFileStream 实现的限制,它只能与 Sql Server 2008 一起使用。
从逻辑上讲,我看不出为什么不能在 Sql Server 2000 和 Sql Server 2005 上提供某些 API 的任何原因。
- 有谁知道这是否已完成?
- 任何地方都有这个开源实现吗?
- 我认为这应该是可能的,我错过了什么?
For the background to this question,
see “How to I serialize a large
graph of .NET object into a SQL Server
BLOB without creating a large
buffer?” that now has a large
bounty on it.
SqlFileStream gives you an IoStream that sits on top of a blob (varbinary) value that is stored in the database. However due to limitations on SqlFileStream implementation it will only work with Sql Server 2008.
Logically I can’t see any reason why the some API cannot be provided on Sql Server 2000 and Sql Server 2005.
- Does anyone know if this has been done?
- Is there an open source implementation of this anywhere?
- What am I missing in thinking it should be possible?
发布评论
评论(3)
我不知道 SqlFileStream SQL Server 2008 以外的任何类。我怀疑这完全是因为 SqlFileStream 类专门设计为“位于”FILESTREAM 类型的列之上SQL Server 2008 中。
FILESTREAM
列/数据类型< /a> 仅在 SQL Server 2008 中可用,本质上允许在此列中存储大量数据。FILESTREAM
列实际上是带有FILESTREAM
修饰符的varbinary(max)
列。这本质上会导致 SQL Server 有效地绕过 RDBMS 存储子系统,并将二进制数据直接存储在底层 NTFS 文件系统上,同时从 RDBMS 角度保持该数据的事务完整性。MSDN 文章这样指出:
SQL Server 2008 中的 FILESTREAM 数据 MSDN 文章还指出:
但还有一点:
建议在内部,SqlFileStream 以与“bog-standard”相同的方式运行
FileStream
class但是,也许最能说明问题的细节是为什么此功能在早期版本的 SQL Server 中不可用(未实现任何类型的 FILESTREAM 或“ direct-to-underlying-storage”列类型)来自 FILESTREAM 概述 MSDN 文章指出:
这本质上是说,使用 SqlFileStream 对象的行为几乎与“标准”FileStream 对象相同,除了 SQL Server(出于事务完整性目的)将充当一个非常轻量级的“看门人”(或“包装器”)来读写由于以前版本的 SQL Server 没有提供此类功能以及与底层 NTFS 文件系统的直接集成,因此我认为不可能针对任何版本的 SQL 实现 SqlFileStream。 SQL Server 2008 之前的服务器。(至少没有一个具有相同的“写入文件,但维护 RDBMS 事务完整性”功能)。
I don't know of a SqlFileStream class for anything other than SQL Server 2008. I suspect this is entirely down the fact that the
SqlFileStream
class is specifically designed to "sit on top of" a column of typeFILESTREAM
within SQL Server 2008.The
FILESTREAM
column/datatype is only available in SQL Server 2008 and essentially allows large volumes of data to be stored in this column. AFILESTREAM
column is actually avarbinary(max)
column with aFILESTREAM
modifier. This essentially causes the SQL Server to effectively bypass the RDBMS storage sub-system and store the binary data directly on the underlying NTFS file system, whist maintaining transactional integrity for this data from the RDBMS perspective.The MSDN article states this thusly:
The FILESTREAM Data in SQL Server 2008 MSDN article also states that:
But also that:
Suggesting that, internally, the SqlFileStream operates in the same manner as a "bog-standard"
FileStream
classHowever, perhaps the most telling details as to why this functionality is not available in prior versions of SQL Server (that do not implement any type of FILESTREAM or "direct-to-underlying-storage" column type) is from the FILESTREAM Overview MSDN article that states:
This essentially says that using a SqlFileStream object will act almost identically to a "standard" FileStream object, except that SQL Server (for transactional integrity purposes) will act as a very lightweight "gatekeeper" (or "wrapper) for your reading and writing of binary data to an underlying NTFS file system file. Since no previous version of SQL Server has offered such functionality and direct integration with the underlying NTFS file system, I'd say that it would not be possible to implement a SqlFileStream against any version of SQL Server prior to SQL Server 2008. (At least not one that has the same "write to a file, but maintain RDBMS transactional integrity" features).
FILESTREAM 数据类型是在 SQL Server 2008 中引入的,在 SQL Server 2005 中没有等效数据类型。此数据类型的处理方式与“普通”blob 类型不同。 FILESTREAM 数据作为文件单独保存在数据库中,而 blob(文本或 varchar(max) 等)则直接保存在数据页内。因此,您可以在 SQL 2008 中使用 SqlFileStream 流式传输文件内容,但要读取 blob,数据库引擎必须将它们加载到服务器内存中并作为整体返回给客户端。因此,不可能将 SqlFileStream 等任何内容直接附加到 SQL 2005 中的 blob 列。
The FILESTREAM datatype was introduced in SQL Server 2008 and there is no equivalent in SQL Server 2005. This datatype is handled differently than a 'normal' blob type. FILESTREAM data are kept separately to the database as files, while blobs (text or varchar(max) and alike) are kept directly within data pages. So, you can stream contents of files with SqlFileStream in SQL 2008, but to read blobs, db engine has to load them into server memory and return to client as a whole. Because of that it is not possible to have anything like SqlFileStream attached directly to a blob column in SQL 2005.
请参阅如何在不创建大缓冲区的情况下将大型 .NET 对象图序列化为 SQL Server BLOB?
see How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?