gpt4 book ai didi

postgresql - 如何在postgresql中存储多语言字符串?

转载 作者:行者123 更新时间:2023-12-05 07:45:00 30 4
gpt4 key购买 nike

如何在postgresql中存储多语言字符串?

这个问题不是这样的:

  1. Best way to store images in PostgreSQL [duplicate]
  2. How to design a database schema for storing text in multiple languages?
  3. Best practise for storing multilingual strings

我想在一张表中插入带有日语、韩语、中文(简体和繁体)和俄语字符的字符串。

INSERT INTO articles (title, text, date)
VALUES ('article title', 'Long text with chinese (龙), korean(울), japanese(形) and russian(ЯД) characters', '2017-02-16');

如何在 Postgresql 中使用正确的 LC_COLLATE 和 LC_CTYPE 为表中的多语言字符串创建数据库?

CREATE DATABASE "articles"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'zh_CN.UTF-8'
LC_CTYPE = 'zh_CN.UTF-8'
TEMPLATE = template0;

CREATE DATABASE "articles"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'zh_TW.UTF-8'
LC_CTYPE = 'zh_TW.UTF-8'
TEMPLATE = template0;

CREATE DATABASE "articles"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'ko_KR.UTF-8'
LC_CTYPE = 'ko_KR.UTF-8'
TEMPLATE = template0;

CREATE DATABASE "articles"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'ja_JP.UTF-8'
LC_CTYPE = 'ja_JP.UTF-8'
TEMPLATE = template0;

CREATE DATABASE "articles"
WITH OWNER "postgres"
ENCODING 'UTF8'
LC_COLLATE = 'ru_RU.UTF-8'
LC_CTYPE = 'ru_RU.UTF-8'
TEMPLATE = template0;

在 postgresql 中存储多语言文本的最佳实践是什么?

最佳答案

为了在一个表中存储多种语言,我使用了下面的代码及其工作

CREATE TABLE TESTING1(COL VARCHAR(100))

INSERT INTO TESTING1 (COL)
SELECT 'ЯНВАРЬ';

在这里,插入俄语文本,您可以插入任何语言数据,如日语、科伦语、泰尔古语等。

please refer the below link for more information

关于postgresql - 如何在postgresql中存储多语言字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42271811/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com