本文摘自GBASE南大通用社區(qū),by:wty,原文請點擊:GBase 8s常見問題 -- 字符集相關(guān)問題|GBASE社區(qū)|天津南大通用數(shù)據(jù)技術(shù)股份有限公司|GBASE-致力于成為用戶最信賴的數(shù)據(jù)庫產(chǎn)品供應(yīng)商
23103 ? Code-set conversion function failed due to an illegal sequence or invalid value.
字符集轉(zhuǎn)換失敗,字符串中出現(xiàn)非法字符
1. 數(shù)據(jù)庫是英文字符集,在sysmaster系統(tǒng)庫中查sysdbslocale表來確定數(shù)據(jù)庫是什么字符集
[gbasedbt@test ~]$ dbaccess sysmaster -
Database selected.
> select * from sysdbslocale;
dbs_dbsname sysmaster
dbs_collate en_US.819
dbs_dbsname sysutils
dbs_collate en_US.819
dbs_dbsname sysuser
dbs_collate en_US.819
dbs_dbsname sysadmin
dbs_collate en_US.819
dbs_dbsname db_utf8
dbs_collate zh_CN.57372
dbs_dbsname db_gb18030
dbs_collate zh_CN.5488
dbs_dbsname db_en
dbs_collate en_US.819
7 row(s) retrieved.
>
en_US.819 : 英文
zh_CN.57372 :UTF-8 ,同zh_CN.UTF8
zh_CN.5488 : GB18030-2000,兼容gbk,同zh_CN.GB18030-2000
2. 如果是在連接數(shù)據(jù)庫時報此錯誤,有可能是客戶端/jdbc/應(yīng)用程序放在含有中文的目錄中,導(dǎo)致數(shù)據(jù)無法插入到系統(tǒng)庫中,不能正常連接數(shù)據(jù)庫。
-23197 ? Database locale information mismatch.
DB_LOCALE參數(shù)或環(huán)境變量與數(shù)據(jù)庫不一致
按上面的方法查詢數(shù)據(jù)庫的字符集,修改配置
[gbasedbt@test ~]$ dbaccess db_utf8 -
23197: Database locale information mismatch.
[gbasedbt@test ~]$ export DB_LOCALE=zh_cn.utf8
[gbasedbt@test ~]$ dbaccess db_utf8 -
Database selected.
>
-23101 ? Unable to load locale categories.
字符集參數(shù)或環(huán)境變量配置錯誤,一般是配置了錯誤的值,導(dǎo)致無法識別
可以先去掉字符集配置,再按上面的方法查詢數(shù)據(jù)庫的字符集,修改配置
[gbasedbt@test ~]$ export DB_LOCALE=zh_cn.utf123
[gbasedbt@test ~]$ dbaccess sysmaster -
23101: Unable to load locale categories.
[gbasedbt@test ~]$ unset DB_LOCALE
[gbasedbt@test ~]$ dbaccess sysmaster -
Database selected.
>
修改現(xiàn)有數(shù)據(jù)庫的字符集
不支持直接修改數(shù)據(jù)庫字符集,需要先將數(shù)據(jù)庫導(dǎo)出,配置新字符集之后,新建數(shù)據(jù)庫或?qū)霐?shù)據(jù)庫
下面舉例將utf-8字符集的數(shù)據(jù)庫通過導(dǎo)入導(dǎo)出的方式,重建為gb18030字符集
1. 配置DB_LOCALE、CLIENT_LOCALE環(huán)境變量,使用dbexport導(dǎo)出數(shù)據(jù)庫
[gbasedbt@test ~]$ export DB_LOCALE=zh_cn.utf8
[gbasedbt@test ~]$ export CLIENT_LOCALE=zh_cn.utf8
[gbasedbt@test ~]$ dbexport testdb -ss
{ DATABASE testdb delimiter | }
grant dba to "gbasedbt";、
...
dbexport completed
[gbasedbt@test ~]$
2. 刪除或重命名原庫(如果新庫不需要與原庫同名,可以跳過此步驟)
重命名:
[gbasedbt@test ~]$ dbaccess sysmaster -
Database selected.
> rename database testdb to testdb1;
Database renamed.
>
刪除:
[gbasedbt@test ~]$ dbaccess sysmaster -
Database selected.
> drop database testdb;
Database dropped.
>
3. 修改DB_LOCALE,將剛才導(dǎo)出的數(shù)據(jù)庫導(dǎo)入
如果沒有刪除/重命名原數(shù)據(jù)庫,需要修改導(dǎo)出文件名為新的庫名
1)修改導(dǎo)出的文件夾名:testdb.exp ?> ?testdb1.exp
2)修改數(shù)據(jù)庫對象SQL文件:testdb.sql ?> ?testdb1.sql ? 此文件在導(dǎo)出的文件夾里
3)修改Oracle模式對象SQL文件:testdb_ora.sql ?> ?testdb_ora1.sql ? 此文件在導(dǎo)出的文件夾里(如果沒有可以忽略)
*注意:此步驟不要修改CLIENT_LOCALE環(huán)境變量,CLIENT_LOCALE環(huán)境變量對應(yīng)的是導(dǎo)出文件的字符集
[gbasedbt@test ~]$ export CLIENT_LOCALE=zh_cn.gb18030-2000
[gbasedbt@test ~]$ dbimport testdb -d datadbs01 -l
{ DATABASE testdb delimiter | }
grant dba to "gbasedbt";
...
dbimport completed
set environment sqlmode 'oracle';
...
set environment sqlmode 'gbase';
[gbasedbt@test ~]$
導(dǎo)入命令:dbimport testdb -d datadbs01 -l
testdb :庫名,對應(yīng)上述導(dǎo)出文件中三個文件的文件名
-d datadbs01 :指定存儲的dbspace,使用onstat -d查詢dbspace信息文章來源:http://www.zghlxwxcb.cn/news/detail-821466.html
-l :指定導(dǎo)入數(shù)據(jù)庫的日志模式為無緩存日志,不指定默認(rèn)使用無日志模式,指定有緩存模式使用 -l buffered文章來源地址http://www.zghlxwxcb.cn/news/detail-821466.html
到了這里,關(guān)于GBASE南大通用數(shù)據(jù)庫GBase 8s常見問題講堂 -- 字符集的設(shè)置的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!