'COLLATE SQL_Latin1_General_CP1_CI_AS' 有什么作用?

What does #39;COLLATE SQL_Latin1_General_CP1_CI_AS#39; do?(COLLATE SQL_Latin1_General_CP1_CI_AS 有什么作用?)
本文介绍了'COLLATE SQL_Latin1_General_CP1_CI_AS' 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 SQL 查询来在 SQLServer 中创建数据库,如下所示:

I have an SQL query to create the database in SQLServer as given below:

create database yourdb
on
( name = 'yourdb_dat',
  filename = 'c:program filesmicrosoft sql servermssql.1mssqldatayourdbdat.mdf',
  size = 25mb,
  maxsize = 1500mb,
  filegrowth = 10mb )
log on
( name = 'yourdb_log',
  filename = 'c:program filesmicrosoft sql servermssql.1mssqldatayourdblog.ldf',
  size = 7mb,
  maxsize = 375mb,
  filegrowth = 10mb )
COLLATE SQL_Latin1_General_CP1_CI_AS;
go

运行良好.

虽然 SQL 的其余部分很明显,但我对 COLLATE SQL_Latin1_General_CP1_CI_AS 的功能感到非常困惑.

While rest of the SQL is clear to be I am quite confused about the functionality of COLLATE SQL_Latin1_General_CP1_CI_AS.

谁能给我解释一下?另外,我想知道以这种方式创建数据库是否是最佳实践?

Can anyone explain this to me? Also, I would like to know if creating the database in this way is a best practice?

推荐答案

它设置数据库服务器如何排序(比较文本片段).在这种情况下:

It sets how the database server sorts (compares pieces of text). in this case:

SQL_Latin1_General_CP1_CI_AS

分解成有趣的部分:

  1. latin1 使服务器使用字符集 latin 1 处理字符串,基本上是 ascii
  2. CP1 代表代码页 1252
  3. CI 不区分大小写的比较,所以 'ABC' 将等于 'abc'
  4. AS 区分重音,所以 'ü' 不等于 'u'
  1. latin1 makes the server treat strings using charset latin 1, basically ascii
  2. CP1 stands for Code Page 1252
  3. CI case insensitive comparisons so 'ABC' would equal 'abc'
  4. AS accent sensitive, so 'ü' does not equal 'u'

PS 有关更多详细信息,请务必阅读@solomon-rutzky 的回答.

P.S. For more detailed information be sure to read @solomon-rutzky's answer.

这篇关于'COLLATE SQL_Latin1_General_CP1_CI_AS' 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
SSIS: Model design issue causing duplications - can two fact tables be connected?(SSIS:模型设计问题导致重复-两个事实表可以连接吗?)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)
SQL Server Graph Database - shortest path using multiple edge types(SQL Server图形数据库-使用多种边类型的最短路径)
Invalid column name when using EF Core filtered includes(使用EF核心过滤包括时无效的列名)
How should make faster SQL Server filtering procedure with many parameters(如何让多参数的SQL Server过滤程序更快)