字符类型的数据库物理存储

时间:2020-11-25 16:51:46

For SQL Server 2005/2008, after some self-study, I am not sure whether my understanding about how character data type is physically stored is correct. Please help to review and comment. Here is my understanding, please review and feel free to correct me.

对于SQL Server 2005/2008,经过一些自学,我不确定我对字符数据类型的物理存储方式的理解是否正确。请帮助审核和评论。以下是我的理解,请查看并随时纠正我。

  • when using unicode character type (e.g. nvarchar), underlying character are stored in UCS-2 encoding (i.e. character is stored physically in the form of related UCS-2 defined bit sequences for the character). Collation defines comparison and sorting, no codepage in this situation;

    当使用unicode字符类型(例如nvarchar)时,基础字符以UCS-2编码存储(即,字符以物理上相关的UCS-2定义的比特序列的形式存储)。整理定义了比较和排序,在这种情况下没有代码页;

  • when using non-unicode character type (e.g. varchar), underlying character are stored physically as bits defined in related code page defined by collation. So in this case, collation defines not only comparison/sorting, but also which codepage (character, bit value represents the character, and using the same bit value to store the character in database physical storage).

    当使用非unicode字符类型(例如varchar)时,底层字符在物理上存储为由collat​​ion定义的相关代码页中定义的位。因此,在这种情况下,归类不仅定义了比较/排序,还定义了哪个代码页(字符,位值表示字符,并使用相同的位值将字符存储在数据库物理存储中)。

thanks in advance, George

乔治,提前谢谢

1 个解决方案

#1


I think you are wright ,see the link for further info http://www.sql-server-helper.com/faq/data-types-p01.aspx

我认为你是正确的,请参阅更多信息的链接http://www.sql-server-helper.com/faq/data-types-p01.aspx

#1


I think you are wright ,see the link for further info http://www.sql-server-helper.com/faq/data-types-p01.aspx

我认为你是正确的,请参阅更多信息的链接http://www.sql-server-helper.com/faq/data-types-p01.aspx