当前位置: 代码迷 >> Sybase >> Sybase字符集批改
  详细解决方案

Sybase字符集批改

热度:1055   发布时间:2016-05-05 09:15:49.0
Sybase字符集修改
数据库字符集的修改的地方为两部分,服务端和客户端,并且两处必须修改一致,unix和windows操作系统就字符集修改这一部分大同小异,不同之处就是客户端修改的时候略有不同,考虑到目前windows系统较多,所以下面以windows系统下的sybase数据库字符集修改为例。
目前国内字符集:cp936

修改步骤如下:
1、首先查找数据库当前字符集
C:\Users\wsb>isql -U<usrname> -P<passwd> -S<dbname>
1> sp_helpsort
2> go

Collation Name                 Collation ID
------------------------------ ------------
defaultml                                20
thaidict                                 21
iso14651                                 22
utf8bin                                  24
binary                                   25
altnoacc                                 39
altdict                                  45
altnocsp                                 46
scandict                                 47
scannocp                                 48
dict                                     51
nocase                                   52
nocasep                                  53
noaccent                                 54
espdict                                  55
espnocs                                  56
espnoac                                  57
rusnocs                                  59
cyrnocs                                  64
elldict                                  65
hundict                                  69
hunnoac                                  70
hunnocs                                  71
turknoac                                 73
turknocs                                 74

Loadable Sort Table Name       Collation ID
------------------------------ ------------
cp932bin                                129
dynix                                   130
gb2312bn                                137
cyrdict                                 140
turdict                                 155
euckscbn                                161
gbpinyin                                163
rusdict                                 165
sjisbin                                 179
eucjisbn                                192
big5bin                                 194

Sort Order Description

------------------------------
Character Set = 2, cp850
     Code Page 850 (Multilingual) character set.
Sort Order = 50, bin_cp850
     Binary ordering, for use with Code Page 850 (cp850).
Characters, in Order

------------------------------
     ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?
   @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _
   ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ 
   ????????????????????????? ???????
   ????????????????? ? ? ? ? ????? ? ? ? ???
   ? ? ? ? ? ? ??? ? ? ? ? ? ? ??????? ???? ? ? ? ???
   ??????????????????? ???????????? ?

WARNING!  Some character(s) could not be converted into client's character set.

Unconverted bytes were changed to question marks ('?').
(return status = 0)
2、由上面反映结果可以得知,目前的字符集为cp850,同时也看到cp936字符集当前库中还不存在,需要手工进行安装,安装命令为:
Charset  -U<usrname> -P<passwd> -S<dbname> binary.srt cp936



3、完成cp936字符集包的安装后,查找cp936字符集在数据库中的id,一般为171,查找方法如下:
6> select name,id from syscharsets
7> go
name                           id
------------------------------ ---
ascii_8                          0
iso_1                            1
cp850                            2
defaultml                       20
thaidict                        21
iso14651                        22
utf8bin                         24
binary                          25
altnoacc                        39
altdict                         45
altnocsp                        46
scandict                        47
scannocp                        48
bin_iso_1                       50
bin_cp850                       50
bin_cp936                       50
dict                            51
nocase                          52
nocasep                         53
noaccent                        54
espdict                         55
espnocs                         56
espnoac                         57
rusnocs                         59
cyrnocs                         64
elldict                         65
hundict                         69
hunnoac                         70
hunnocs                         71
turknoac                        73
turknocs                        74
cp932bin                       129
dynix                          130
gb2312bn                       137
cyrdict                        140
turdict                        155
euckscbn                       161
gbpinyin                       163
rusdict                        165
cp936                          171
sjisbin                        179
eucjisbn                       192
big5bin                        194

(43 rows affected)
4、手工设置字符集为171,方法如下:
1>  sp_configure 'default character set id',171
2> go
In changing the default sort order, you have also reconfigured SQL Server's
default character set.
Parameter Name                 Default     Memory Used Config Value
         Run Value   Unit                 Type
------------------------------ ----------- ----------- ------------
         ----------- -------------------- ----------
default character set id                 2           0         171
                   2 id                   static

(1 row affected)
Configuration option changed. Since the option is static, Adaptive Server must
be rebooted in order for the change to take effect.
Changing the value of 'default character set id' to '171' increases the amount
of memory ASE uses by 6 K.
(return status = 0)
1>
5、客户端字符集修改:
用记事本打开%SYBASEHOME% \locales\ locales.dat中的NT下面的loca=default


6、手工重启数据库,一般第一次启动会启动失败,这很正常,再次启动数据库,数据库启动正常后,进行字符集验证。

本文地址:http://www.xszlo.com/article/2012-09-24/7454.html,转发请保留这个地址,谢谢