如何存储不同的文档类型 [英] How to store different document types

查看:150
本文介绍了如何存储不同的文档类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用SQL SERVER 2008的网站,它允许用户上传excel,word,txt,pdf,媒体文件等格式的文件。 (就像Rapishare,Megaupload)



将它们存储到SQL SERVER中的最佳方式是什么? 解决方案

FILESTREAM VARBINARY(MAX) ,但你应该考虑这样做的优点和缺点,而不是将文件存储在文件系统中,只是指向数据库中的文件。

将文件存储在数据库中的优点:

$ ul

  • 事务一致性
  • 安全性(假设你需要它并且你的数据库不是很宽打开)


    $缺点:$ b​​
    $ b $ ul
  • 更大的数据库文件+备份(如果您托管在其他人的存储上,这可能代价高昂)
  • 更难以调试(不能在管理中说SELECT doc FROM table工作室,并有Word弹出)

  • 更难以向用户展示文档(并允许他们上传) - 而不是只提供文件系统上文件的链接,您必须构建一个应用程序来获取文件并将其存储在数据库中,从数据库中提取文件以将其呈现给用户。



  • 在SQL Server 2012中, FileTable 将提供更有用的混合。


    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)

    What is the best way to store them into SQL SERVER ?

    解决方案

    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.

    这篇关于如何存储不同的文档类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆