Character Sets and Collations in MySQL : COLLATION Character Set « Table « MySQL Tutorial

MySQL Tutorial
1. Introduction
2. Select Query
3. Database
4. Table
5. Table Join
6. Subquery
7. Insert Update Delete
8. Logic Operator
9. View
10. Data Types
11. Procedure Function
12. Cursor
13. Trigger
14. Date Time Functions
15. Comparison Functions Operators
16. Aggregate Functions
17. Cast Functions Operators
18. Control Flow Functions
19. Encryption Compression Functions
20. Information Functions
21. Math Numeric Functions
22. Miscellaneous Functions
23. String Functions
24. Regular Expressions
25. Data Dictionary
26. MySQL Utilities
27. Privilege
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
MySQL Tutorial » Table » COLLATION Character Set 
4. 20. 1. Character Sets and Collations in MySQL

MySQL supports the use of character sets for the MyISAM, MEMORY, NDBCluster, and InnoDB storage engines.

A character set is a set of symbols and encodings.

A collation is a set of rules for comparing characters in a character set.

The MySQL server can support multiple character sets.

To list the available character sets, use the SHOW CHARACTER SET statement

Quote from MySQL document http://www.mysql.com

mysql>
mysql> SHOW CHARACTER SET;
+----------+-----------------------------+---------------------+--------+
| Charset  | Description                 | Default collation   | Maxlen |
+----------+-----------------------------+---------------------+--------+
| big5     | Big5 Traditional Chinese    | big5_chinese_ci     |      |
| dec8     | DEC West European           | dec8_swedish_ci     |      |
| cp850    | DOS West European           | cp850_general_ci    |      |
| hp8      | HP West European            | hp8_english_ci      |      |
| koi8r    | KOI8-R Relcom Russian       | koi8r_general_ci    |      |
| latin1   | cp1252 West European        | latin1_swedish_ci   |      |
| latin2   | ISO 8859-Central European | latin2_general_ci   |      |
| swe7     | 7bit Swedish                | swe7_swedish_ci     |      |
| ascii    | US ASCII                    | ascii_general_ci    |      |
| ujis     | EUC-JP Japanese             | ujis_japanese_ci    |      |
| sjis     | Shift-JIS Japanese          | sjis_japanese_ci    |      |
| hebrew   | ISO 8859-Hebrew           | hebrew_general_ci   |      |
| tis620   | TIS620 Thai                 | tis620_thai_ci      |      |
| euckr    | EUC-KR Korean               | euckr_korean_ci     |      |
| koi8u    | KOI8-U Ukrainian            | koi8u_general_ci    |      |
| gb2312   | GB2312 Simplified Chinese   | gb2312_chinese_ci   |      |
| greek    | ISO 8859-Greek            | greek_general_ci    |      |
| cp1250   | Windows Central European    | cp1250_general_ci   |      |
| gbk      | GBK Simplified Chinese      | gbk_chinese_ci      |      |
| latin5   | ISO 8859-Turkish          | latin5_turkish_ci   |      |
| armscii8 | ARMSCII-Armenian          | armscii8_general_ci |      |
| utf8     | UTF-Unicode               | utf8_general_ci     |      |
| ucs2     | UCS-Unicode               | ucs2_general_ci     |      |
| cp866    | DOS Russian                 | cp866_general_ci    |      |
| keybcs2  | DOS Kamenicky Czech-Slovak  | keybcs2_general_ci  |      |
| macce    | Mac Central European        | macce_general_ci    |      |
| macroman | Mac West European           | macroman_general_ci |      |
| cp852    | DOS Central European        | cp852_general_ci    |      |
| latin7   | ISO 8859-13 Baltic          | latin7_general_ci   |      |
| cp1251   | Windows Cyrillic            | cp1251_general_ci   |      |
| cp1256   | Windows Arabic              | cp1256_general_ci   |      |
| cp1257   | Windows Baltic              | cp1257_general_ci   |      |
| binary   | Binary pseudo charset       | binary              |      |
| geostd8  | GEOSTD8 Georgian            | geostd8_general_ci  |      |
| cp932    | SJIS for Windows Japanese   | cp932_japanese_ci   |      |
| eucjpms  | UJIS for Windows Japanese   | eucjpms_japanese_ci |      |
+----------+-----------------------------+---------------------+--------+
36 rows in set (0.00 sec)

mysql>

Any given character set always has at least one collation.

Any given character set may have several collations.

To list the collations for a character set, use the SHOW COLLATION statement.

mysql>
mysql> SHOW COLLATION LIKE 'latin1%';
+-------------------+---------+----+---------+----------+---------+
| Collation         | Charset | Id | Default | Compiled | Sortlen |
+-------------------+---------+----+---------+----------+---------+
| latin1_german1_ci | latin1  |  |         | Yes      |       |
| latin1_swedish_ci | latin1  |  | Yes     | Yes      |       |
| latin1_danish_ci  | latin1  | 15 |         | Yes      |       |
| latin1_german2_ci | latin1  | 31 |         | Yes      |       |
| latin1_bin        | latin1  | 47 |         | Yes      |       |
| latin1_general_ci | latin1  | 48 |         | Yes      |       |
| latin1_general_cs | latin1  | 49 |         | Yes      |       |
| latin1_spanish_ci | latin1  | 94 |         | Yes      |       |
+-------------------+---------+----+---------+----------+---------+
rows in set (0.00 sec)

mysql>
4. 20. COLLATION Character Set
4. 20. 1. Character Sets and Collations in MySQL
4. 20. 2. Server Character Set and Collation
4. 20. 3. Every database has a database character set and a database collation.
4. 20. 4. List the available character set
4. 20. 5. TEXT CHARACTER SET latin1 COLLATE latin1_bin
4. 20. 6. character_set_system
4. 20. 7. Using alter command to change characgter set
4. 20. 8. The output from SHOW COLLATION includes all available character sets.
4. 20. 9. The SHOW CHARACTER SET command shows all available character sets.
4. 20. 10. Table and Column Definition with character and collate
4. 20. 11. Database, Table, and Column Definition with Character and collate
4. 20. 12. SHOW CREATE DATABASE displays the CREATE DATABASE statement that creates a given database:
4. 20. 13. SHOW CREATE TABLE displays the CREATE TABLE statement to create a given table.
4. 20. 14. The SHOW COLUMNS statement displays the collations of a table's columns when invoked as SHOW FULL COLUMNS
4. 20. 15. Table Character Set and Collation
4. 20. 16. Column Character Set and Collation
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.