This is a discussion on import data - how to change code page on the fly within the MySQL Database forums, part of the Database Forums category; hello, my database has table in latin2. Flat file with data which I would like to import to db is ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
hello,
my database has table in latin2. Flat file with data which I would like to import to db is coded in cp1250 charset. As far as I know there is no way to import data to db and auto-magic change code page of data on the fly. Am I correct?:) And main question I kindly ask you: why following set of queries give me wrong results: SET NAMES binary; --I supposed that means "dont interpret future data" LOAD DATA infile (...cut....) -- loading data... SET NAMES cp1250; --ok, let talk with me in cp1250 code page select * from t; --no way! db returns data as latin2 according to table charset why "SET NAMES cp1250" is ignored? regards, Robert |
|
|||
|
== Quote from aaooo54 (roobik@poczta.onet.pl)'s article
> hello, > my database has table in latin2. Flat file with data which I would like to > import to db is coded in cp1250 charset. > As far as I know there is no way to import data to db and auto-magic change > code page of data on the fly. Am I correct?:) > And main question I kindly ask you: why following set of queries give me > wrong results: > SET NAMES binary; --I supposed that means "dont interpret future data" > LOAD DATA infile (...cut....) -- loading data... > SET NAMES cp1250; --ok, let talk with me in cp1250 code page > select * from t; --no way! db returns data as latin2 according to table > charset > why "SET NAMES cp1250" is ignored? > regards, > Robert it is possible that the column definitions have latin2 encoding. if this is the case it wouldn't matter what language you set yourself up in the command line, the table attributes won't understand it. post a description of the table and a sample of your data infile if you can. -- POST BY: lark with PHP News Reader ;o) |
|
|||
|
> it is possible that the column definitions have latin2 encoding.
ok, i have checked with table definied as CHARSET=cp1250 import script is as follow: SET NAMES cp1250; SET CHARACTER SET cp1250; LOAD DATA ... flat file is saved as cp1250 for sure. Error occured when script tried insert first column with character specified to cp1250 code page and innconsistent with code page of database (latin2) Ridiculous mysql message is "Data truncation: Data too long for column" At the moment my workaround is to change code page of flat file before I import them to the db but I believe that solution exists in mysql;) regards, R. |