I'm trying to attach one database to another but they have different
encoding schemas. One is UTF-16le and the other is UTF-8. I get this error
message when I try to attach:

Error: attached databases must use the same text encoding as main database

According to the sqlite FAQ, once an encoding has been set for a database,
it cannot be changed. Fair enough. But is it possible to *recreate* an
existing database and set the encoding type before the create table
statements are run?

I tried doing this to the table that uses UTF-16le:

  BEGIN TRANSACTION;
  CREATE TEMPORARY TABLE tmp(...);
  INSERT INTO tmp(...) SELECT ... FROM questions;
  DROP TABLE mytable;
  PRAGMA encoding = "UTF-8";
  CREATE TABLE mytable(...);
  INSERT INTO mytable(...) SELECT ... FROM tmp;
  COMMIT;

But it didn't work, the newly rebuilt database was still UTF-16le. Any
suggestions on this? I'm a sqlite n00b and not a database specialist, so
verbosity in your responses would be much appreciated. ;)

Thanks in advance.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to