5

If I create a FileTable in SQL server 2012, and then was to drop a 4G file onto the NT filesystem (that was in the filestream), would that entire 4G file be read into the table's filestream column?

Is SQL in fact making a COPY of my 4G file? Or does the filestream column represent a pointer to my 4G file, which it begins to read on a query?

Im just trying to figure out if I added 100G of data to my file system, would that add 100G of data size to my DB.

Can someone help explain how this works? And even better point me to some docs with more detail than the MS/MSDN 'how-to' stuff?

EDIT: It's interesting- if I drop a 1G file in the FT dir, and then do a select the file_stream column contains all the data for that file (I think). But if I do sp_spaceused FileTableTb before and after dropping in that file the table size does not change. Perhaps this is evidence that the select opens the stream to the file and reads it in, but other than that the data is NOT stored in the table?

4

1 回答 1

4

您是对的,数据不是存储在数据库中而是存储在文件系统本身中,同样重要的是要注意,当文件放在文件系统上时,文件并没有“读入”到数据库中,这意味着它被复制到另一个位置,它实际上存储为 NTFS 文件,并且 FileStream API 显示文件表中的文件元数据。

文件表基于 SQL 2008 中引入的 FileStream 技术构建,但允许您通过 Windows 资源管理器直接修改数据。

创建数据库时,您指定其中一个文件组是文件流文件组,这与普通文件组不同,实际上是一系列称为数据容器的 NTFS 文件夹,这是您的文件实际存储的位置,您可以t 直接修改此文件夹,但您可以查看内容(虽然这里没有太多人类可读的东西,但如果您通过 GUID 文件夹和奇怪的命名文件仔细查看,您可以在此处找到您的实际文件 :)) .

用于将文件复制到表中的文件共享实际上是这些数据容器内的数据的表示,这些数据通过过滤器驱动程序呈现给 Windows 资源管理器,该过滤器驱动程序使用流 API 对数据容器进行更改并添加行到文件表等。

于 2013-05-02T16:10:49.770 回答