问题
Let's say i want to build a website that will hold a very large number (at least 10 millions) of small files (around 50KB, mostly PDF
, but also word/excel documents, jpg, and text files).
Using SQL Server 2008
database, what are the different technical possibilities to store these files (eg: using a table with for filenames + filesystem for data, using varbinary, etc...) ?
回答1:
SQL Server 2008 database provider many datatypes to store binary data.
FILESTREAM datatype was introduced in SQL Server 2008, They offer the capability to store binary data to the database. But With a small amount of binary data, it's not efficient to use a file stream, Because it needs extra overhead like file creation and handling In SQL Server 2008. FILESTREAM storage is not right for your situation In my opinion its best for
- When the average 1MB or higher.
- When encryption is not required, as it is not supported for FILESTREAM data
On the other hand varbinary datatype is mpore suitable in your case, The advantages is saving storage space and keeping an accurate representation of the data.
In general FILESTREAM is good for larger files and VARBINARY for smaller ones.
Also It will be good to store files directly into database as they are really less in size.
here you can read more about it - Database: image file as blob or file path?
Hope it will help
回答2:
You should try FILESTREAM
http://msdn.microsoft.com/en-us//library/bb933993(v=sql.105).aspx
FILESTREAM integrates the SQL Server Database Engine with an NTFS file system by storing varbinary(max) binary large object (BLOB) data as files on the file system
also, if you can upgrade to sql2012, take a look on FileTable feature (which is based on FILESTREAM) - it supports full-text and semantic search http://msdn.microsoft.com/en-us/library/ff929144.aspx
回答3:
Files should be just indexed into database (filenames and whatever else you need there). Database should contain pathes to these files but not files because it would kill your DB.
来源:https://stackoverflow.com/questions/17442690/what-are-the-different-possibilities-to-store-a-large-number-of-files-in-a-sql-s