ALTER DATABASE

Overview

Modifies database characteristics, such as changing the default character-set and collation.

USAGE

Common Syntax:

ALTER {DATABASE | SCHEMA} <db_name>
  [ [DEFAULT] COLLATE [=] <xpand_collation_name> ]
  [ [DEFAULT] {CHARACTER SET | CHARSET} [=] <xpand_charset_name> ]

DETAILS

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

Change Character Set and Collation

Character sets define which characters can be used to store information in a database. A collation is a set of rules for sorting and comparing character sets, for example:

  • In a case-insensitive collation, "Sofia" and "sofia" would be considered the same name

  • In a case-sensitive collation, "Robert" and "robert" would be considered different names

If you do not specify a character set and collation for a database, the defaults will be used. The default character set and collation are determined by the character_set_server and collation_server system variables. If the system variables are not changed, the default character set is utf8, and the default collation is utf8_general_ci.

To change a character set and/or collation to be used as the default for all newly created tables within a database:

ALTER DATABASE db1
   DEFAULT CHARACTER SET = 'utf8mb4'
   DEFAULT COLLATE = 'utf8mb4_unicode_ci';

The DEFAULT reserved word and equal sign (=) are optional. This is the equivalent statement:

ALTER DATABASE db1
   CHARACTER SET 'utf8mb4'
   COLLATE 'utf8mb4_unicode_ci';

You can set a different database character set and/or collation for tables within the database using the CREATE TABLE or ALTER TABLE statement.

For additional information on character sets and collations, see "Character Sets in MariaDB Xpand" and "Collations in MariaDB Xpand".

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES