MySQL 5.0 Reference Manual  /  ...  /  ALTER DATABASE Syntax

13.1.1 ALTER DATABASE Syntax

    alter_specification ...

    [DEFAULT] CHARACTER SET [=] charset_name
  | [DEFAULT] COLLATE [=] collation_name

ALTER DATABASE enables you to change the overall characteristics of a database. These characteristics are stored in the db.opt file in the database directory. To use ALTER DATABASE, you need the ALTER privilege on the database. ALTER SCHEMA is a synonym for ALTER DATABASE as of MySQL 5.0.2.

The CHARACTER SET clause changes the default database character set. The COLLATE clause changes the default database collation. Section 10.1, “Character Set Support”, discusses character set and collation names.

You can see what character sets and collations are available using, respectively, the SHOW CHARACTER SET and SHOW COLLATION statements. See Section, “SHOW CHARACTER SET Syntax”, and Section, “SHOW COLLATION Syntax”, for more information.

If you change the default character set or collation for a database, stored routines that use the database defaults must be dropped and recreated so that they use the new defaults. (In a stored routine, variables with character data types use the database defaults if the character set or collation are not specified explicitly. See Section 13.1.9, “CREATE PROCEDURE and CREATE FUNCTION Syntax”.)

The database name can be omitted, in which case the statement applies to the default database.

User Comments
  Posted by Chris Wilson on November 23, 2010
You can check the collation and other options of an existing database using the "SHOW CREATE DATABASE" statement.
Sign Up Login You must be logged in to post a comment.