How to store different document types

后端 未结 2 872
迷失自我
迷失自我 2021-01-28 17:04

I have a website which is using SQL SERVER 2008 which allows user to upload files like excel, word, txt, pdf, media files and other format also. (Just like Rapishare, Megaupload

相关标签:
2条回答
  • 2021-01-28 17:34

    FILESTREAM or VARBINARY(MAX), but you should consider the pros and cons of doing so versus storing the files on the file system and just a pointer to the file in the database.

    Pros for storing files in the database:

    • transactional consistency
    • security (assuming you need it and that your database isn't wide open anyway)

    Cons:

    • much larger database files + backups (which can be costly if you are hosting on someone else's storage)
    • much more difficult to debug (you can't say "SELECT doc FROM table" in Management Studio and have Word pop up)
    • more difficult to present the documents to users (and allow them to upload) - instead of just presenting a link to a file on the file system, you must build an app that takes the file and stores it in the database, and pulls the file from the database to present it to the user.

    In SQL Server 2012, FileTable will offer a more usable hybrid.

    0 讨论(0)
  • 2021-01-28 17:37

    Since you use SQL Server 2008 you might look into the filestream feature. This should be an efficient way to store binary data from files with sizes over 1 MB file size.

    0 讨论(0)
提交回复
热议问题