.rar或.zip保存到SQL Server [英] .rar or .zip saved to SQL Server

查看:137
本文介绍了.rar或.zip保存到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有一种方法可以将.rar或.zip文件上传到sql服务器,然后再次将其取回?

谢谢,

Hi,

Is there a way to upload a .rar or .zip file to sql server and get it back again?

Thanks,

推荐答案

请参阅我对问题的评论.但是,它可以使用BLOB来实现:
http://en.wikipedia.org/wiki/Binary_blob [ http://msdn.microsoft.com/en-us/library/bb895234.aspx [ ^ ].

—SA
Please see my comment to the question. However, it can do it with BLOB:
http://en.wikipedia.org/wiki/Binary_blob[^],
http://msdn.microsoft.com/en-us/library/bb895234.aspx[^].

—SA


是的-只需将其读取为字节序列,然后将其保存在varbinary(max)列中即可.您以相同的方式检索它,然后可以将其再次另存为zip/rar文件.

但是,我强烈建议您反对:zip/rar文件通常用于非常大的对象,并且大多数数据库都有最大大小限制,并且在您插入,更新或选择它们时会引起大量数据库流量.将它们保存在一个单独的基于文件系统的文件夹中,而不是临时名称(例如Guid),然后将原始名称和Guid路径存储在数据库中,这可能更有意义.
Yes - just read it as a sequence of bytes and save it in a varbinary(max) column. You retrieve it the same way, and can then save it as a zip / rar file again.

However, I would strongly suggest against it: zip / rar files tend to be used for very large objects, and most databases have a maximum size limit as well as causing a lot of database traffic when you insert, update or select them. It might make a lot more sense to keep them in a separate file-system based folder instead, under a temporary name (a Guid for example) and store the original name and the Guid path in the DB instead.


这篇关于.rar或.zip保存到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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