ALTER DATABASE

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

Sintassi

ALTER {DATABASE | SCHEMA} [nome_db]
    specifica_alter ...
ALTER {DATABASE | SCHEMA} nome_db
    UPGRADE DATA DIRECTORY NAME

alter_specification:
    [DEFAULT] CHARACTER SET [=] nome_charset
  | [DEFAULT] COLLATE [=] nome_collation

Spiegazione

ALTER DATABASE permette di modificare le caratteristiche generali di un database. Queste sono scritte nel file db.opt nella directory del database. Per utilizzare ALTER DATABASE occorre il privilegio ALTER sul database interessato. ALTER SCHEMA è sinonimo di ALTER DATABASE.

La clausola CHARACTER SET modifica il set di caratteri di default del database. La clausola COLLATE modifica la collation di default del database. La pagina http://dev.mysql.com/doc/refman/5.1/en/charset.html illustra i set di caratteri e le collation.

E' possibile sapere quali set di caratteri e quali collation sono supportati usando, rispettivamente, le istruzioni SHOW CHARACTER SET e SHOW COLLATION. Si vedano [HELP SHOW CHARACTER SET] e [HELP SHOW COLLATION] per ulteriori informazioni.

Il nome del database può essere omesso nella prima sintassi, nel qual caso l'istruzione agirà sul database corrente.

The syntax that includes the UPGRADE DATA DIRECTORY NAME clause was added in MySQL 5.1.23. It updates the name of the directory associated with the database to use the encoding implemented in MySQL 5.1 for mapping database names to database directory names (see http://dev.mysql.com/doc/refman/5.1/en/identifier-mapping.html). This clause is for use under these conditions:

  • It is intended when upgrading MySQL to 5.1 or later from older versions.
  • It is intended to update a database directory name to the current encoding format if the name contains special characters that need encoding.
  • The statement is used by mysqlcheck (as invoked by mysql_upgrade).

For example,if a database in MySQL 5.0 has a name of a-b-c, the name contains instance of the `-' character. In 5.0, the database directory is also named a-b-c, which is not necessarily safe for all file systems. In MySQL 5.1 and up, the same database name is encoded as a@002db@002dc to produce a file system-neutral directory name.

When a MySQL installation is upgraded to MySQL 5.1 or later from an older version,the server displays a name such as a-b-c (which is in the old format) as #mysql50#a-b-c, and you must refer to the name using the #mysql50# prefix. Use UPGRADE DATA DIRECTORY NAME in this case to explicitly tell the server to re-encode the database directory name to the current encoding format:

ALTER DATABASE `#mysql50#a-b-c` UPGRADE DATA DIRECTORY NAME;

After executing this statement, you can refer to the database as a-b-c without the special #mysql50# prefix.

See Also:

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.