ALTER DATABASE  enables you to change the overall characteristics of a database. These characteristics are stored in the data dictionary. This statement requires the ALTER  privilege on the database. ALTER SCHEMA  is a synonym for ALTER DATABASE . 

If the database name is omitted, the statement applies to the default database. In that case, an error occurs if there is no default database. 

For any alter_option  omitted from the statement, the database retains its current option value, with the exception that changing the character set may change the collation and vice versa. 

## Character Set and Collation Options 

•Character Set and Collation Options 

•Encryption Option 

•Read Only Option 

The CHARACTER SET  option changes the default database character set. The COLLATE  option changes the default database collation. For information about character set and collation names, see Chapter 10, Character Sets, Collations, Unicode . 

To see the available character sets and collations, use the SHOW CHARACTER SET  and SHOW COLLATION  statements, respectively. See Section 13.7.7.3, “SHOW CHARACTER SET Statement” , and Section 13.7.7.4, “SHOW COLLATION Statement” . 

A stored routine that uses the database defaults when the routine is created includes those defaults as part of its definition. (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.17, “CREATE PROCEDURE and CREATE FUNCTION Statements” .) If you change the default character set or collation for a database, any stored routines that are to use the new defaults must be dropped and recreated. 

## Encryption Option 

The ENCRYPTION  option, introduced in MySQL 8.0.16, defines the default database encryption, which is inherited by tables created in the database. The permitted values are ’Y’  (encryption enabled) and ’N’  (encryption disabled). Only newly created tables inherit the default database encryption. For existing tables associated with the database, their encryption remains unchanged. If the table_encryption_privilege_check  system variable is enabled, the TABLE_ENCRYPTION_ADMIN privilege is required to specify a default encryption setting that differs from the value of the default_table_encryption  system variable. For more information, see Defining an Encryption Default for Schemas and General Tablespaces. 

## Read Only Option 

The READ ONLY  option, introduced in MySQL 8.0.22, controls whether to permit modification of the database and objects within it. The permitted values are DEFAULT  or 0  (not read only) and 1  (read only). This option is useful for database migration because a database for which READ ONLY  is enabled can be migrated to another MySQL instance without concern that the database might be changed during the operation. 

With NDB Cluster, making a database read only on one mysqld  server is synchronized to other mysqld servers in the same cluster, so that the database becomes read only on all mysqld  servers. 

The READ ONLY  option, if enabled, is displayed in the INFORMATION_SCHEMA SCHEMATA_EXTENSIONS table. See Section 26.3.32, “The INFORMATION_SCHEMA SCHEMATA_EXTENSIONS Table” . 

