Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SELECT ... INTO OUTFILE & Charset

1,111 views
Skip to first unread message

Ryan Chan

unread,
Oct 9, 2009, 10:30:06 AM10/9/09
to
Hello,

From the doc: http://dev.mysql.com/doc/refman/5.0/en/select.html

It said:

...SELECT ... INTO OUTFILE... Column
values are dumped using the binary character set.

Is it possible to export the OUTFILE as latin1 or UTF8 with SELECT ...
INTO OUTFILE syntax?


Thanks

Peter H. Coffin

unread,
Oct 9, 2009, 11:08:06 AM10/9/09
to

You can SELECT using CONVERT(colname USING latin1) for all the columns
you want in latin1, etc.

--
When C++ is your hammer, everything looks like a thumb.
-- Steven M. Haflich

Ryan Chan

unread,
Oct 9, 2009, 12:28:38 PM10/9/09
to
On Oct 9, 11:08 pm, "Peter H. Coffin" <hell...@ninehells.com> wrote:
>
> You can SELECT using CONVERT(colname USING latin1) for all the columns
> you want in latin1, etc.
>

Yes, already tried, in the console it print correct character, but
when exported to file using ".. INTO OUTFILE..", it still showing
strange characters.

Peter H. Coffin

unread,
Oct 9, 2009, 6:08:03 PM10/9/09
to

Unless you're piping that file through xxd or some similar hex-viewing
tool, how do you know exactly whether it's weird or right? (And I hope
you know what utf8 data looks like when it's right at a glance... I do,
but I work with the stuff every day. Is a field with "Campo Mourão" in
it screwed up or are you just looking at it with a terminal using a
different encoding?

--
CANNIBAL, n.
A gastronome of the old school who preserves the simple tastes and adheres
to the natural diet of the pre-pork period.

Ryan Chan

unread,
Oct 10, 2009, 9:36:07 AM10/10/09
to
Hello,

On Oct 10, 6:08 am, "Peter H. Coffin" <hell...@ninehells.com> wrote:
> Unless you're piping that file through xxd or some similar hex-viewing
> tool, how do you know exactly whether it's weird or right?

The column contains UTF8 characters,

if I use "tee /tmp/1.sql", and issue the select query, it give me the
correct encoding.

If I use select into outfile, it give me weired encoding.

Both files are viewed in OpenOffice, and different encoding settings.

0 new messages