Re: setting character set for inserts and updates
Posted by: Attila Rákos
Date: December 18, 2005 05:06PM

You can set the default character set and collation of a database in the CREATE DATABASE statement:

CREATE DATABASE db_name CHARACTER SET latin2 COLLATE latin2_general_ci;

This determines the character set and collation of tables and columns where you do not specify exactly which one to use. If you have an existing database, you can change its default character set with the ALTER DATABASE db_name CHARACTER SET latin2 COLLATE latin2_general_ci command but it has no effect on the already existing tables and columns, so you have to change the character set for each column one by one with the ALTER TABLE command. May be easier if you export the existing database to SQL and then simply replace the character set and collation names with proper ones in the text file and then recreate the database.

If your database, tables and columns already have the proper character set, then you should set the default-character-set option in the [mysqld] section of my.inf/cnf to the preferred value (and restart the server) or better to issue a SET NAMES latin2 statment from your program after establishing connection (the latter one is independent of the server's configuration, so you can use multiple databases with different character sets on the same server).

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: setting character set for inserts and updates
1808
December 18, 2005 05:06PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.