• <legend id='Mg5YM'><style id='Mg5YM'><dir id='Mg5YM'><q id='Mg5YM'></q></dir></style></legend>

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

      <tfoot id='Mg5YM'></tfoot>
    2. <small id='Mg5YM'></small><noframes id='Mg5YM'>

        • <bdo id='Mg5YM'></bdo><ul id='Mg5YM'></ul>
      1. 在 SQL Server 上使用 varchar(MAX) 与 TEXT

        时间:2023-09-18
          <tbody id='6pAE4'></tbody>
        • <bdo id='6pAE4'></bdo><ul id='6pAE4'></ul>

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

                <legend id='6pAE4'><style id='6pAE4'><dir id='6pAE4'><q id='6pAE4'></q></dir></style></legend>

                <small id='6pAE4'></small><noframes id='6pAE4'>

                  本文介绍了在 SQL Server 上使用 varchar(MAX) 与 TEXT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我刚刚读到 VARCHAR(MAX) 数据类型(可以存储接近 2GB 的字符数据)是 SQL Server 2005 中 TEXT 数据类型的推荐替代品和下一个 SQL SERVER 版本.

                  I just read that the VARCHAR(MAX) datatype (which can store close to 2GB of char data) is the recommended replacement for the TEXT datatype in SQL Server 2005 and Next SQL SERVER versions.

                  如果我想在列内搜索任何字符串,哪个操作更快?

                  If I want to search inside a column for any string, which operation is quicker?

                  1. VARCHAR(MAX) 列使用 LIKE 子句?

                  WHERE COL1 LIKE '%search string%'

                  使用TEXT列并在此列上放置全文索引/目录,然后使用CONTAINS 子句?

                  Using the TEXT column and put a Full Text Index/Catalog on this column, and then search using the CONTAINS clause?

                  WHERE CONTAINS (Col1, 'MyToken')

                  推荐答案

                  VARCHAR(MAX) 类型是 TEXT 的替代.基本区别在于 TEXT 类型将始终将数据存储在 blob 中,而 VARCHAR(MAX) 类型将尝试将数据直接存储在行中,除非它超过8k 限制,然后将其存储在 blob 中.

                  The VARCHAR(MAX) type is a replacement for TEXT. The basic difference is that a TEXT type will always store the data in a blob whereas the VARCHAR(MAX) type will attempt to store the data directly in the row unless it exceeds the 8k limitation and at that point it stores it in a blob.

                  使用 LIKE 语句在两种数据类型之间是相同的.VARCHAR(MAX) 为您提供的附加功能是它也可以像任何其他 VARCHAR 一样与 =GROUP BY 一起使用 列即可.但是,如果您确实有大量数据,则使用这些方法会遇到巨大的性能问题.

                  Using the LIKE statement is identical between the two datatypes. The additional functionality VARCHAR(MAX) gives you is that it is also can be used with = and GROUP BY as any other VARCHAR column can be. However, if you do have a lot of data you will have a huge performance issue using these methods.

                  关于是否应该使用 LIKE 进行搜索,或者是否应该使用 Full Text IndexingCONTAINS.不管VARCHAR(MAX)还是TEXT,这个问题都是一样的.

                  In regard to if you should use LIKE to search, or if you should use Full Text Indexing and CONTAINS. This question is the same regardless of VARCHAR(MAX) or TEXT.

                  如果您要搜索大量文本并且性能是关键,那么您应该使用全文索引.

                  If you are searching large amounts of text and performance is key then you should use a Full Text Index.

                  LIKE 实现更简单,通常适用于少量数据,但由于无法使用索引,在处理大数据时性能极差.

                  LIKE is simpler to implement and is often suitable for small amounts of data, but it has extremely poor performance with large data due to its inability to use an index.

                  这篇关于在 SQL Server 上使用 varchar(MAX) 与 TEXT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python将numpy数组插入到sqlite3数据库中 下一篇:如何在 Python sqlite3 中将现有的 db 文件加载到内存中?

                  相关文章

                  • <bdo id='f1p43'></bdo><ul id='f1p43'></ul>

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

                    <legend id='f1p43'><style id='f1p43'><dir id='f1p43'><q id='f1p43'></q></dir></style></legend>
                  1. <small id='f1p43'></small><noframes id='f1p43'>

                    <tfoot id='f1p43'></tfoot>