LightDB服务端支持GBK/GB18030编码

背景介绍

LightDB在23.3版本之前仅客户端支持GBK/GB18030编码。在23.3版本中,LightDB服务端支持了GBK/GB18030编码格式存储数据,并且将支持的GB18030标准升级到了2022版。

服务端和客户端对应的编码格式如下表。

服务端编码支持的客户端编码
GBKGBK, UTF-8
GB18030GB18030, UTF-8

如果在GBK/GB18030编码中含有0x40–0x7E这些特殊值,则不可以使用这些汉字去命名database、schema、relation和column。

使用说明

  1. 创建GBK/GB18030数据库。
lightdb@postgres=# create database gbktest encoding='gbk' locale='zh_CN.gbk' template template0;
CREATE DATABASE
lightdb@postgres=# create database gb18030test encoding='gb18030' locale='zh_CN.gb18030' template template0;
CREATE DATABASE
lightdb@postgres=# \l
                                   List of databases
    Name     |  Owner  | Encoding |    Collate    |     Ctype     |  Access privileges  
-------------+---------+----------+---------------+---------------+---------------------
 gb18030test | lightdb | GB18030  | zh_CN.gb18030 | zh_CN.gb18030 | 
 gbktest     | lightdb | GBK      | zh_CN.gbk     | zh_CN.gbk     | 
 lt_test     | lightdb | UTF8     | zh_CN.UTF-8   | zh_CN.UTF-8   | 
 postgres    | lightdb | UTF8     | zh_CN.UTF-8   | zh_CN.UTF-8   | 
 template0   | lightdb | UTF8     | zh_CN.UTF-8   | zh_CN.UTF-8   | =c/lightdb         +
             |         |          |               |               | lightdb=CTc/lightdb
 template1   | lightdb | UTF8     | zh_CN.UTF-8   | zh_CN.UTF-8   | =c/lightdb         +
             |         |          |               |               | lightdb=CTc/lightdb
(6 rows)

lightdb@postgres=# 
  1. 连接到数据库,查看数据库编码;
lightdb@postgres=# \c gb18030test 
You are now connected to database "gb18030test" as user "lightdb".
lightdb@gb18030test=# show server_encoding ;
 server_encoding 
-----------------
 GB18030
(1 row)

lightdb@gb18030test=# \c gbktest 
You are now connected to database "gbktest" as user "lightdb".
lightdb@gbktest=# show server_encoding ;
 server_encoding 
-----------------
 GBK
(1 row)

lightdb@gbktest=# 
  1. 可以像其他数据库一样正常使用。
lightdb@gbktest=# create table t1(id int, addr text);
CREATE TABLE
lightdb@gbktest=# \d
        List of relations
 Schema | Name | Type  |  Owner  
--------+------+-------+---------
 public | t1   | table | lightdb
(1 row)

lightdb@gbktest=# \c gb18030test 
You are now connected to database "gb18030test" as user "lightdb".
lightdb@gb18030test=# create table t1(id int, addr text);
CREATE TABLE
lightdb@gb18030test=# \d
        List of relations
 Schema | Name | Type  |  Owner  
--------+------+-------+---------
 public | t1   | table | lightdb
(1 row)

lightdb@gb18030test=# 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值