SET CHARSET

Function

Sets the character encoding type of the client.

Precautions

  • This statement is equivalent to set client_encoding in openGauss.
  • Set this parameter based on the front-end service requirements. Ensure that the client code is the same as the server code to improve efficiency.
  • It is compatible with all encoding types of PostgreSQL.

Syntax

SET {CHARACTER SET | CHARSET} {'charset_name' | DEFAULT}

Parameter Description

  • {CHARACTER SET | CHARSET}

     The two are equivalent.
    
  • {'charset_name' | DEFAULT}

     charset\_name supports the character encoding types that can be set by openGauss, such as utf8 and gbk. If DEFAULT is specified, the character set is reset to the default one.
     charset\_name supports the following formats:
    
     1. utf8
     2. 'utf8'
     3. "utf8"
    

Examples

openGauss=# show client_encoding;
-[ RECORD 1 ]---+----
client_encoding | GBK

openGauss=# set charset gbk;
SET
db_show=# show client_encoding;
-[ RECORD 1 ]---+----
client_encoding | GBK

openGauss=# set charset default;
SET
openGauss=# show client_encoding;
-[ RECORD 1 ]---+-----
client_encoding | UTF8

openGauss=# set character set 'gbk';
SET
openGauss=# show client_encoding;
-[ RECORD 1 ]---+----
client_encoding | GBK

openGauss=# set character set default;
SET
openGauss=# show client_encoding;
-[ RECORD 1 ]---+-----
client_encoding | UTF8
Feedback
编组 3备份
    openGauss 2024-05-19 00:42:09
    cancel