which charset use for cyrilic?
Hi
Which charset is need to be set in database for cyrilic?
I've used till now WIN, but today I found a problem
for example:
SELECT *
FROM table
WHERE a = 'пїЅпїЅпїЅпїЅпїЅ'
returns me a record, where a = 'пїЅпїЅпїЅпїЅпїЅ'
after I tried UNICODE
but for most of cyrilic words PG gives error like
"invalid byte sequence for encoding "UNICODE":..."
Regards,
Zet
Import Notes
Reply to msg id not found: 6BCB9D8A16AC4241919521715F4D8BCE92E7B7@algol.sollentuna.seReference msg id not found: 6BCB9D8A16AC4241919521715F4D8BCE92E7B7@algol.sollentuna.se
Zet,
there is pgsql-ru-general list (russian), btw.
see http://www.postgresql.org/community/lists/subscribe for
subscription info.
You did't get us enough info and examples (cut'n paste form psql would be
nice).
Oleg
On Sat, 29 Oct 2005, Zet wrote:
Hi
Which charset is need to be set in database for cyrilic?
I've used till now WIN, but today I found a problem
for example:
SELECT *
FROM table
WHERE a = 'О©╫О©╫О©╫О©╫О©╫'returns me a record, where a = 'О©╫О©╫О©╫О©╫О©╫'
after I tried UNICODE
but for most of cyrilic words PG gives error like
"invalid byte sequence for encoding "UNICODE":..."Regards,
Zet---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
From pgsql-general-owner@postgresql.org Sat Oct 29 12:08:04 2005
X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org
Received: from localhost (av.hub.org [200.46.204.144])
by svr1.postgresql.org (Postfix) with ESMTP id 2B977DB330
for <pgsql-general-postgresql.org@localhost.postgresql.org>; Sat, 29 Oct 2005 12:08:03 -0300 (ADT)
Received: from svr1.postgresql.org ([200.46.204.71])
by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024)
with ESMTP id 65280-05
for <pgsql-general-postgresql.org@localhost.postgresql.org>;
Sat, 29 Oct 2005 15:08:00 +0000 (GMT)
Received: from wolff.to (wolff.to [66.93.197.194])
by svr1.postgresql.org (Postfix) with SMTP id 274F1DB325
for <pgsql-general@postgresql.org>; Sat, 29 Oct 2005 12:07:59 -0300 (ADT)
Received: (qmail 1780 invoked by uid 500); 29 Oct 2005 15:09:53 -0000
Date: Sat, 29 Oct 2005 10:09:53 -0500
From: Bruno Wolff III <bruno@wolff.to>
To: NosyMan <nosyman@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Can I use variable to store sql data?
Message-ID: <20051029150953.GA29677@wolff.to>
Mail-Followup-To: Bruno Wolff III <bruno@wolff.to>,
NosyMan <nosyman@gmail.com>, pgsql-general@postgresql.org
References: <20051016175758.97106.qmail@web32713.mail.mud.yahoo.com> <200510170955.50217.nosyman@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <200510170955.50217.nosyman@gmail.com>
User-Agent: Mutt/1.4.2.1i
X-Virus-Scanned: by amavisd-new at hub.org
X-Spam-Status: No, score=0.006 required=5 tests=[AWL=0.006]
X-Spam-Score: 0.006
X-Spam-Level:
X-Archive-Number: 200510/1791
X-Sequence-Number: 86019
Please post questions to relevant lists. This question did not belong on
the patches list. I have moved the discussion to the general list.
Please don't reply to other threads to start new ones. This messes up the
archives and won't help people see your question.
On Mon, Oct 17, 2005 at 09:55:50 +0300,
NosyMan <nosyman@gmail.com> wrote:
Hi,
The scenario:
SELECT id_product FROM products WHERE product_code='PRD-030';Now I want to insert id_product into another table :
INSERT INTO product_sales( id_product, sale_date)
INSERT INTO product_sales( id_product, sale_date)
INSERT INTO product_sales( id_product, sale_date)
You can do something like:
INSERT INTO product_sales values (
(SELECT id_product FROM products WHERE product_code='PRD-030'),
sales_date);
Also if id_product was just assigned a value from a sequence in the same
session, you could use the currval function to get its value.
Am Samstag, den 29.10.2005, 13:11 +0400 schrieb Zet:
Hi
Which charset is need to be set in database for cyrilic?
I've used till now WIN, but today I found a problem
win?
for example:
SELECT *
FROM table
WHERE a = 'яПНяПНяПНяПНяПН'returns me a record, where a = 'яПНяПНяПНяПНяПН'
after I tried UNICODE
but for most of cyrilic words PG gives error like
"invalid byte sequence for encoding "UNICODE":..."
Well for cyrillic, you have the following options:
cp-1251 (windows codepage)
koi-8 (traditional charset)
utf-8 (universal, if you want to have latin characters coexist
with cyrillic. This is also what you get with the
UNICODE setting in PG)
You should use the same encoding in the database as
you use in your application to make things easier.
Now you have some data already in your database.
So if you want to change the encoding, you need
to recode your char, varchar and text.
1. ) find out the setting of your database:
show server_encoding()
if this matches, what you want, you are ready with
this step.
if you get something like SQL_ASCII, then you dont
know what charset actually got used - inspect your
application in this case which encoding it used
to store text.
Make a complete backup, check your
lc_* variables:
SHOW LC_MESSAGES; (and so on)
If its not something like
ru_RU@utf8 (if its UNICODE you want to use)
Then you better run initdb again with the
correct locales setting. This is important
for lower(),upper(), ilike, oder by, etc.
to work.
recreate your DB with setting UNICODE (or
whatever you want to use - same as with the
locales)
create a text dump out of your dump via
pg_restore (its recommended to backup using pg_dump -Fc)
relace the occurences of
SET CLIENT_ENCODING TO '...'; (this is what your
original database had) With what you now want
as encoding:
SET CLIENT_ENCODING TO 'UNICODE';
(this can be done with sed if you dont want
to load all the dump in your editor)
restore the database with the new cript.
Postgres will take care of the charset conversion.