English 中文(简体)
SQL 2008: Filestream versus Binaries in the database
原标题:

Yesterday I asked the question on how I should save my files. After some research I ve desided to go with storing the files "in" the database.

I ve checked the difference between storing the files using filestream and storing the files in the database itself.

Each has it s advantages and disadvantages. To help me with my research this site helped me out a lot: http://www.codeproject.com/KB/database/SqlFileStream.aspx

So basically it says that saving the files using filestream is better if the files are bigger than 1mb.

But I ve discovered another problem with filestreaming. If you delete a record in the database the file still exists on the filesystem.

Therefore I need you guys opinion. What to use? Filestream or saving the files in the database using VARBINARY?

Grtz, M.

最佳回答

The data on the filesystem will (should) be removed soon after you delete the data from the database, though this is done in a separate system background thread, so it may remain on the filesystem until basically the garbage collector runs again. However, all results accessed through any of the filestream APIs (i.e. tsql or streaming) will be guaranteed to not access anything that has been removed, whether or not the filesystem data still resides on disk (ACID is ensured with filestream).

问题回答

Use Filestreams.

Databases are designed to store relational data, file systems are designed to store files.

I heard often from Microsoft employees that storing large blobs in an SQL Server 2000/2005 (cant remember) is not a good idea.

Also consider Backup: A Databasefile is ONE file (EDIT: If you configure it so). If you re using Filestreams you can backup individual files.





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签