1

I understand that collation can be set differently in different tables in a database. Collation is understood from What does character set and collation mean exactly?

There is a query that performs CAST from a char results as shown below. There are no tables involved. I guess, the encoding applied will be based on the collation in database level. Is this assumption correct?

SELECT  CAST ( SSS.id_encrypt ('E','0000000{0}') AS CHAR(100) FOR BIT DATA)  
AS ENCRYPT_ID FROM FFGLOBAL.ONE_ROW FETCH  FIRST 1 ROW ONLY

QUESTION

In the question Get Byte[] from Db2 without Encoding answer given by @AlexFilipovici [.Net BlockCopy ] provides a different result when compared to CAST result. Why is it so if there is no codepage associated?

Based on National language support - Character conversion

Bit data (columns defined as FOR BIT DATA, or BLOBs, or binary strings) is not associated with any character set.

REFERENCE

  1. Get Byte[] from Db2 without Encoding
  2. Default code page for new databases is Unicode
  3. National language support - Character conversion
4

2 回答 2

1

要在 SQL Server 中找出数据库级别的排序规则,请尝试以下操作:

SELECT DATABASEPROPERTYEX('databasename', 'Collation');

更多:DATABASEPROPERTYEX

于 2013-03-06T07:15:11.017 回答
1

要回答您的问题:

#1:指定FOR BIT DATA基于字符的数据类型(在 DB2 中)意味着 DB2 存储/返回原始数据,不关联任何代码页(即它只是一个字节字符串,不会在客户端和服务器之间进行任何代码页转换) .

#2:在 DB2 for Linux, UNIX and Windows 中,您可以通过查询来确定数据库的排序规则SYSIBMADM.DBCFG

 select name,value
  from sysibmadm.dbcfg
 where name in ('codepage','codeset');

#3:根据@Iswanto San:

SELECT DATABASEPROPERTYEX('databasename', 'Collation');
于 2013-03-06T21:12:08.037 回答