As mentioned, MySQL handles character set and collation at several levels: server, database, table, column. Speaking of stored data, of course, what is relevant is what charset is used for each column (CHAR, VARCHAR or TEXT). All values of the higher level, then, are only intended to function as a default for the respective lower level. At the server level and we default_character_set default_collation variables, for which the usual rules apply for the variables of the system: for example, can therefore be initialized by an option file, and even modified at runtime. In the absence of initializing the default charset is latin1 with latin1_swedish_ci collation. Now let's see some examples of SQL definitions:
Code:
CREATE DATABASE db1 [CHARACTER SET utf8] [COLLATE utf8_general_ci];
CREATE TABLE table1 (
Column1 VARCHAR (5) CHARACTER SET latin1 COLLATE latin1_german_ci,
column2 VARCHAR (5) CHARACTER SET latin1,
column3 VARCHAR (10)
) [DEFAULT CHARACTER SET latin1 [COLLATE latin1_general_ci]];
Bookmarks