<bdo id='sKXyH'></bdo><ul id='sKXyH'></ul>
<i id='sKXyH'><tr id='sKXyH'><dt id='sKXyH'><q id='sKXyH'><span id='sKXyH'><b id='sKXyH'><form id='sKXyH'><ins id='sKXyH'></ins><ul id='sKXyH'></ul><sub id='sKXyH'></sub></form><legend id='sKXyH'></legend><bdo id='sKXyH'><pre id='sKXyH'><center id='sKXyH'></center></pre></bdo></b><th id='sKXyH'></th></span></q></dt></tr></i><div id='sKXyH'><tfoot id='sKXyH'></tfoot><dl id='sKXyH'><fieldset id='sKXyH'></fieldset></dl></div>
  1. <small id='sKXyH'></small><noframes id='sKXyH'>

  2. <legend id='sKXyH'><style id='sKXyH'><dir id='sKXyH'><q id='sKXyH'></q></dir></style></legend>

  3. <tfoot id='sKXyH'></tfoot>

      在 SQL Server 中存储图像?

      时间:2023-07-17
    1. <small id='wvkWG'></small><noframes id='wvkWG'>

              • <bdo id='wvkWG'></bdo><ul id='wvkWG'></ul>
                <legend id='wvkWG'><style id='wvkWG'><dir id='wvkWG'><q id='wvkWG'></q></dir></style></legend>

                <tfoot id='wvkWG'></tfoot>
                  <tbody id='wvkWG'></tbody>
                <i id='wvkWG'><tr id='wvkWG'><dt id='wvkWG'><q id='wvkWG'><span id='wvkWG'><b id='wvkWG'><form id='wvkWG'><ins id='wvkWG'></ins><ul id='wvkWG'></ul><sub id='wvkWG'></sub></form><legend id='wvkWG'></legend><bdo id='wvkWG'><pre id='wvkWG'><center id='wvkWG'></center></pre></bdo></b><th id='wvkWG'></th></span></q></dt></tr></i><div id='wvkWG'><tfoot id='wvkWG'></tfoot><dl id='wvkWG'><fieldset id='wvkWG'></fieldset></dl></div>

                本文介绍了在 SQL Server 中存储图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我制作了一个小型演示站点,并在其上将图像存储在 sql server 的图像列中.我有几个问题是...

                I have made a small demo site and on it I am storing images within a image column on the sql server. A few questions I have are...

                • 这是个坏主意吗?

                • Is this a bad idea?

                它会在我的网站增长时影响它的性能吗?

                Will it affect performance on my site when it grows?

                另一种方法是将图像存储在磁盘上,并且只在数据库中存储对图像的引用.这应该是很多人都遇到过的共同困境.我欢迎一些建议,如果可以的话,我实际上很乐意少犯错误.

                The alternative would be to store the image on disc and only store the reference to the image in the database. This must be a common dilemma many people have had. I'd welcome some advice and would actually be happy to make a less of a mistake if I could.

                推荐答案

                Microsoft Research 有一篇非常好的论文,名为 到 Blob 或不 Blob.

                There's a really good paper by Microsoft Research called To Blob or Not To Blob.

                他们经过大量的性能测试和分析得出的结论是:

                Their conclusion after a large number of performance tests and analysis is this:

                • 如果您的图片或文档的大小通常低于 256KB,将它们存储在数据库的 VARBINARY 列中会更有效

                • if your pictures or document are typically below 256KB in size, storing them in a database VARBINARY column is more efficient

                如果您的图片或文档的大小通常超过 1 MB,则将它们存储在文件系统中会更有效(并且使用 SQL Server 2008 的 FILESTREAM 属性,它们仍处于事务控制之下并且是数据库的一部分)

                if your pictures or document are typically over 1 MB in size, storing them in the filesystem is more efficient (and with SQL Server 2008's FILESTREAM attribute, they're still under transactional control and part of the database)

                在这两者之间,根据您的使用情况,有点折腾

                in between those two, it's a bit of a toss-up depending on your use

                如果您决定将图片放入 SQL Server 表中,我强烈建议使用单独的表来存储这些图片 - 不要将员工照片存储在员工表中 - 将它们保存在单独的表中.这样一来,员工表就可以保持简洁和高效,假设您并不总是需要选择员工照片作为查询的一部分.

                If you decide to put your pictures into a SQL Server table, I would strongly recommend using a separate table for storing those pictures - do not store the employee photo in the employee table - keep them in a separate table. That way, the Employee table can stay lean and mean and very efficient, assuming you don't always need to select the employee photo, too, as part of your queries.

                对于文件组,请查看文件和文件组体系结构以获得介绍.基本上,您可以从一开始就为大型数据结构创建具有单独文件组的数据库,或者稍后添加其他文件组.我们称之为LARGE_DATA".

                For filegroups, check out Files and Filegroup Architecture for an intro. Basically, you would either create your database with a separate filegroup for large data structures right from the beginning, or add an additional filegroup later. Let's call it "LARGE_DATA".

                现在,每当您要创建需要存储 VARCHAR(MAX) 或 VARBINARY(MAX) 列的新表时,您都可以为大数据指定此文件组:

                Now, whenever you have a new table to create which needs to store VARCHAR(MAX) or VARBINARY(MAX) columns, you can specify this file group for the large data:

                 CREATE TABLE dbo.YourTable
                     (....... define the fields here ......)
                     ON Data                   -- the basic "Data" filegroup for the regular data
                     TEXTIMAGE_ON LARGE_DATA   -- the filegroup for large chunks of data
                

                查看有关文件组的 MSDN 介绍,并尝试使用它!

                Check out the MSDN intro on filegroups, and play around with it!

                这篇关于在 SQL Server 中存储图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何将 SQL Server 的时间戳列转换为日期时间格式 下一篇:如何在 SQL Server 中截断日期时间?

                相关文章

                  <bdo id='53fa2'></bdo><ul id='53fa2'></ul>

                    <legend id='53fa2'><style id='53fa2'><dir id='53fa2'><q id='53fa2'></q></dir></style></legend>
                  1. <i id='53fa2'><tr id='53fa2'><dt id='53fa2'><q id='53fa2'><span id='53fa2'><b id='53fa2'><form id='53fa2'><ins id='53fa2'></ins><ul id='53fa2'></ul><sub id='53fa2'></sub></form><legend id='53fa2'></legend><bdo id='53fa2'><pre id='53fa2'><center id='53fa2'></center></pre></bdo></b><th id='53fa2'></th></span></q></dt></tr></i><div id='53fa2'><tfoot id='53fa2'></tfoot><dl id='53fa2'><fieldset id='53fa2'></fieldset></dl></div>

                    <tfoot id='53fa2'></tfoot>

                    <small id='53fa2'></small><noframes id='53fa2'>