HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

SET CHARSET

Function

Sets the character encoding type of the client.

Precautions

  • This statement is equivalent to set client_encoding in MogDB.
  • 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 MogDB, 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

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

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

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

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

MogDB=# set character set default;
SET
MogDB=# show client_encoding;
-[ RECORD 1 ]---+-----
client_encoding | UTF8
Copyright © 2011-2024 www.enmotech.com All rights reserved.