Database. opt file of MySQL database

Source: Internet
Author: User
Each MySQL database directory contains a file db. opt, which is mainly used to store the default Character Set and character verification rules of the current database. Eg. default-character-s

Each MySQL database directory contains a file db. opt, which is mainly used to store the default Character Set and character verification rules of the current database. Eg. default-character-s

Each MySQL database directory contains a file db. opt, which is mainly used to store the default Character Set and character verification rules of the current database.

Eg. default-character-set = latin1
Default-collation = latin1_swedish_ci

This file stores the default Character Set and character set validation rules when creating a database. If the database does not specify the character set and validation rules when creating a table in the future, the two attributes of the table are derived from the two tables.

MySQL source code:

/* Set table default charset, if not set
SYNOPSIS
Set_table_default_charset ()
Create_info Table create information
DESCRIPTION
If the table character set was not given explicitely,
Let's fetch the database default character set and
Apply it to the table .*/
Static void set_table_default_charset (THD * thd,
HA_CREATE_INFO * create_info, char * db)
{
If (! Create_info-> default_table_charset)
{
HA_CREATE_INFO db_info;
Load_db_opt_by_name (thd, db, & db_info );
Create_info-> default_table_charset = db_info.default_table_charset;
}
Specify Character Set and character set verification rules when creating a database:
Create database if not exists test default [charset | character set] utf8 default collate utf8_general_ci;
Modify the character set and character set verification rules of the database:
Alter database test default [charset | character set] latin1 default collate latin1_swedish_ci;
Create database
CREATE {DATABASE | SCHEMA} [if not exists] db_name
[Create_specification]…
Create_specification:
[DEFAULT] character set [=] charset_name
| [DEFAULT] COLLATE [=] collation_name
You can also use alter database to modify
ALTER {DATABASE | SCHEMA} [db_name]
Alter_specification...
Alter_specification:
[DEFAULT] character set [=] charset_name
| [DEFAULT] COLLATE [=] collation_name

,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.