Table Character Set and Collation : 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. 15. Table Character Set and Collation

Every table has a table character set and a table collation.

The CREATE TABLE and ALTER TABLE statements have optional clauses for specifying them:

CREATE TABLE tbl_name (column_list)
    [[DEFAULTCHARACTER SET charset_name] [COLLATE collation_name]]

ALTER TABLE tbl_name
    [[DEFAULTCHARACTER SET charset_name] [COLLATE collation_name]

Example:

CREATE TABLE t1 first_name varchar(30) ) CHARACTER SET latin1 COLLATE latin1_danish_ci;

MySQL chooses the table character set and collation in the following manner:

If both CHARACTER SET X and COLLATE Y were specified, then character set X and collation Y.

If CHARACTER SET X was specified without COLLATE, then character set X and its default collation.

If COLLATE Y was specified without CHARACTER SET, then the character set associated with Y and collation Y.

Otherwise, the database character set and collation.

The table character set and collation are used as default values if the column character set and collation are not specified in individual column definitions.

Quote from MySQL document: www.mysql.com

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.