SYBASE字符集的配置:
使用isql登录远程DB服务器:
>>isql -S -U -P -D
1、在操作系统上运行locale
如AIX(IBM的一个UNIX):
LANG=en_US LC_COLLATE="en_US" LC_CTYPE="en_US" LC_MONETARY="en_US" LC_NUMERIC="en_US" LC_TIME="en_US" LC_MESSAGES="en_US" LC_ALL= LANG对应的设置为en_US
2、查看/sybase/locales/locales.dat
找到对应操作系统下的字符集配置,如AIX
[aix] locale = C, us_english, iso_1 locale = En_US, us_english, iso_1 locale = en_US, us_english, iso_1 locale = default, us_english, iso_1 locale = En_US.IBM-850, us_english, cp850 locale = en_US.ISO8859-1, us_english, iso_1 locale = En_JP, us_english, sjis locale = en_JP, us_english, eucjis locale = Fr_FR, french, cp850 locale = fr_FR, french, iso_1 locale = Fr_FR.IBM-850, french, cp850 locale = fr_FR.ISO8859-1, french, iso_1 locale = Fr_CA, french, cp850 locale = fr_CA, french, iso_1 locale = Fr_CA.IBM-850, french, cp850 locale = fr_CA.ISO8859-1, french, iso_1
找到对应locale=en_US的行,如上面为:
locale = en_US, us_english, iso_1
因此SYBASE使用的字符集为iso_1。
3、可以在isql中查看目前使用的字符集
isql -Usa -P >;sp_helpsort >;go
查看客户端使用的字符集:
isql -Usa -P >;select @@client_csname >;go
如果客户端和服务器字符集不一致,便会产生“Error converting client characters into server's character set.”的错误.
简体中文字符集为:cp932,但使用iso_1、utf8等都可以,关键是客户端和服务器字符集要保持一致。
4、更改字符集的方法:
vi /sybase/locales/locales.dat中对应的操作系统中对应的环境变量
1>;select name,id from syscharsets 2>;go
找到你要更改的字符集名称对应的id(假设为117)
1>;sp_configure "default character set id",1 2>;go
以上以AIX为例,AIX上的SYBASE缺省不用更改字符集,但HPUX需要更改的,更改方法参考上面。不更改的话在使用isql,bcp也可通过-J参数制定字符集,如isql -J cp932等。
——转自网络
sybase数据库字符集的修改:
1.查看字符集
1> use master 2> go 1> select id,name from syscharsets 2> go id name --- ------------------------------
2.查看默认字符集
1> sp_configure "default char" 2> go Parameter Name Default Memory Used Config Value Run Value Unit Type ------------------------------ ----------- ----------- ------------ ----------- -------------------- ---------- default character set id 1 0 190 190 id static
3.修改字符集
1> sp_configure "default char", 1 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 1 0 1 190 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' does not increase the amount o memory Adaptive Server uses. (return status = 0)
4.重起数据库2次
5.再次查询
1> sp_configure "default char" 2> go Parameter Name Default Memory Used Config Value Run Value Unit Type ------------------------------ ----------- ----------- ------------ ----------- -------------------- ---------- default character set id 1 0 1 1 id static (1 row affected) (return status = 0)