7.3. Altering Databases


The ALTER DATABASE statement changes options for an existing database. The allowable options are the same as for CREATE DATABASE; that is, CHARACTER SET and COLLATE. The following statement changes the default collation of the mydb database to utf8_polish_ci:

 ALTER DATABASE mydb COLLATE utf8_polish_ci; 

This statement changes both the default character set and collation:

 ALTER DATABASE mydb CHARACTER SET latin1 COLLATE latin1_swedish_ci; 

Changing the default character set or collation affects only creation of new tables in the database. It does not affect existing tables.

The database name is optional for ALTER DATABASE. If no database is named, the statement changes the options for the default database. This requires that there be a currently selected database. Otherwise, an error occurs.

You cannot use ALTER DATABASE to rename a database. One way to accomplish this is to dump the database, create a database with the new name, reload the data into the new database, and drop the old database.



MySQL 5 Certification Study Guide
MySQL 5.0 Certification Study Guide
ISBN: 0672328127
EAN: 2147483647
Year: 2006
Pages: 312

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net