DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(mysql.info.gz) Charset-database

Info Catalog (mysql.info.gz) Charset-server (mysql.info.gz) Charset-defaults (mysql.info.gz) Charset-table
 
 10.3.2 Database Character Set and Collation
 -------------------------------------------
 
 Every database has a database character set and a database collation,
 which may not be null. The `CREATE DATABASE' and `ALTER DATABASE'
 statements have optional clauses for specifying the database character
 set and collation:
 
      CREATE DATABASE DB_NAME
          [[DEFAULT] CHARACTER SET CHARSET_NAME]
          [[DEFAULT] COLLATE COLLATION_NAME]
 
      ALTER DATABASE DB_NAME
          [[DEFAULT] CHARACTER SET CHARSET_NAME]
          [[DEFAULT] COLLATE COLLATION_NAME]
 
 Example:
 
      CREATE DATABASE DB_NAME
          DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
 
 MySQL chooses the database character set and database collation thus:
 
    * 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.
 
    * Otherwise, the server character set and server collation.
 
 
 MySQL's `CREATE DATABASE ... DEFAULT CHARACTER SET ...' syntax is
 analogous to the standard SQL `CREATE SCHEMA ... CHARACTER SET ...'
 syntax. Because of this, it is possible to create databases with
 different character sets and collations on the same MySQL server.
 
 The database character set and collation are used as default values if
 the table character set and collation are not specified in `CREATE
 TABLE' statements. They have no other purpose.
 
 The character set and collation for the default database are available
 as the values of the `character_set_database' and `collation_database'
 system variables.  The server sets these variables whenever the default
 database changes.  If there is no default database, the variables have
 the same value as the corresponding server-level variables,
 `character_set_server' and `collation_server'.
 
Info Catalog (mysql.info.gz) Charset-server (mysql.info.gz) Charset-defaults (mysql.info.gz) Charset-table
automatically generated byinfo2html