SQL中的大文本和图像 [英] Large Text and Images In SQL

查看:76
本文介绍了SQL中的大文本和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL数据库中存储大量文本(例如html页面)是否是一个好主意?还是将其作为html文件存储在文件系统中是一个更好的主意?

Is it a good idea to store large amounts of text (eg html pages) inside your SQL database? Or is it a better idea to store it as html files in the filesystem?

图像也是如此-将图像数据存储在数据库中还是将其存储在磁盘上更好?

The same goes for images - is it a good idea to store image data in the database or better to put them on disk?

例如,存储大量数据会导致我出现性能问题吗?每种存储方式的优缺点是什么?

Will storing large amounts of data cause me performance problems for example? What are the pros and cons of each method of storage?

在数据大小方面,在这种情况下,我正在寻找HTML和图像大小小于500kb(虽然可能小得多)的几页"区域.足以产生您的平均文章/博客条目/等规模的网页.

In terms of the size of data, in this case I am looking in the region of "a few pages" of HTML and images less than about 500kb in size (probably a lot smaller though). Enough to produce your average article/blog entry/etc scale web page.

推荐答案

在数据库中存储二进制数据(文档,图像等)具有一些优点.

Storing binary data (documents, images etc) in the database has some advantages.

  • 您可以通过与要存储的有关文档的信息(名称,日期等)相同的事务来提交文档本身的更新.这意味着您不必担心编写自己的两阶段提交(尽管ISTR SQL Server 2008为此提供了解决方案).

  • You can commit the update of the document itself in the same transaction as the information (name, date etc) you want to store about the document. This means you don't have to worry about writing your own two-phase commit (although ISTR that SQL Server 2008 has a solution for this).

您可以一次备份全部文件(文档和元数据),而不必担心将数据库与文件系统同步

You can back up the whole lot (documents and metadata) at once, without worrying about having to synchronise the database with the file system

您可以非常轻松地通过.NET Web服务交付文档,因为它们直接进入DataTables,并且只需将DataTables放入DataSet并传递就可以轻松进行序列化.

You can deliver documents very simply over .NET web services, since they come straight out into DataTables, and are serialised effortlessly just by putting the DataTables into a DataSet and passing it.

您可以将数据库安全性应用于对象以及其余数据,而不必担心网络文件权限.

You can apply database security to the objects, as to the rest of your data, and not have to worry about network file permissions.

它也确实有一些缺点:

  • 备份可能会很大

  • Backups can get very large

数据库中的二进制对象的大小可能比其最初来自的文件大很多,因此,在客户端-服务器环境中,它可能会增加在网络上打开它们所花费的时间. .

The size of the binary object in the database can be quite a bit larger than the file it originally came from, and therefore in a client-server environment, it can increase the time taken to open them across the network.

根据应用程序的不同,如果必须为大量大型文档提供服务,则可能需要考虑数据库服务器上的负载.

Depending on the application, you might need to consider the load on the database server if it has to serve up a lot of large documents.

所有这些,这是我广泛使用的一种技术,并且效果很好.

All that said, it's a technique I use extensively, and it works very well.

这篇关于SQL中的大文本和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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