本文介绍了有关SQL Server中的重音不区分大小写的问题(Latin1_General_CI_AS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们所有的数据库都是使用默认排序规则( Latin1_General_CI_AS )安装的。

All our databases were installed using the default collation (Latin1_General_CI_AS).

我们计划更改排序规则允许客户搜索带有重音的不敏感内容。

We plan to change the collation to allow clients to search the database with accent insensitivity.

问题:


  1. 负面因素是什么(如果有)口音不敏感的数据库的概念?

  1. What are the negatives (if any) of having an accent insensitive database?

不区分重音的数据库有任何性能开销吗?

Are there any performance overheads for an accent insensitive database?

为什么默认为SQL Server排序规则重音敏感;

Why is the default for SQL Server collation accent sensitive; why would anyone want accent sensitive by default?


推荐答案

严重的是,更改数据库校对是一种皇家痛苦。请参阅codeproject的HOWTO,然后再认真思考!

Seriously, changing database collations is a royal pain. See this HOWTO from codeproject, and then think hard before you do it! This is the EASY way!



  • http://www.codeproject.com/Articles/302405/The-Easy-way-of-changing-Collation-of-all-Database

首先,您可以简单地通过指定为搜索的一部分来允许对重音不敏感的数据库搜索,则不必更改排序规则。

Firstly, you can permit searches of the database with accent insensitivity simply by specifying that as part of the search, you don't necessarily have to change the collation.

 select * from TableName
 where name collate Latin1_General_CI_AI like @parameter

简单为。但是,这会损害索引。

Simple as. However, this will hurt the indexes.

另一种方法是提供一个可单独索引的计算字段。

An alternative is to supply a calculated field which you can index separately.

    create table TableName(
    ix int identity primary key,
    name nvarchar(20) collate latin1_general_ci_as
    )
    go
    alter table TableName
    add  name_AI as name collate latin1_general_CI_AI
    go
    create index IX_TableName_name_AI
    on dbo.TableName(name_AI)

上面的示例将其放在表中,但您也可以创建索引视图。

The example above puts it in the table, but you could just as well create an indexed view.

    create view dbo.TableName_AI
    with schemabinding
    as
    select ix,
    name collate Latin1_general_CI_AI as name
    from dbo.TableName
    go
    -- Need a unique clustered index first
    create unique clustered index IX_TableName_AI_Clustered on dbo.TableName_AI(ix)
    -- then the index for searching
    create index IX_TableName_AI_name on dbo.TableName_AI(name)

然后,不区分重音搜索,请使用视图 TableName_AI

Then, for accent-insensitive searches, use the view TableName_AI.

要回答您的特定问题:


  1. 在不区分重音的数据库中,对重音敏感的搜索会更慢。

  1. In an accent insensitive database, accent sensitive searches will be slower.

是,但是不,所以您会注意到

Yes, but not so you would notice

它就是这样。必须使用默认值:如果您不喜欢它,请不要使用默认值!

It just is. Something has to be the default: If you don't like it don't use the default!

这样想:硬和硬不是同一个词。一个元音的差异就足够了-即使它们听起来相似。

Think of it this way: "Hard" and "Herd" are not the same word. That one vowel difference is enough - even though they sound similar.

重音差异(a与á)介于大小写差异(A与a)和字母差异(a​​与e)之间。您必须在某处画线。

An accent difference (a vs. á) is somewhere between a case difference (A vs. a), and a letter difference (a vs e). You have to draw the line somewhere.

重音会影响单词的发音,并且可以使单词具有不同的含义,尽管我很难考虑示例。我想这对于那些在数据库中使用重音符号语言的人来说更有意义。

An accent affects the sound of the word and can make it have a different meaning, though I struggle to think of examples. I guess it makes more sense to someone who has words in their database in a language which makes use of accents.

这篇关于有关SQL Server中的重音不区分大小写的问题(Latin1_General_CI_AS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-18 02:01