MySQL 8.0-13.1.12 CREATE DATABASE Statement

CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name
    [create_option] ...

create_option: [DEFAULT] {
    CHARACTER SET [=] charset_name
  | COLLATE [=] collation_name
  | ENCRYPTION [=] {'Y' | 'N'}
}

CREATE_DATEBASE creates a database with the given name. To use this statement, you need the CREATE privilege for the database. CREATE SCHEMA is a synonym for CREATE DATABASE.

CREATE_DATEBASE使用给定的名称创建数据库。要使用此语句,您需要数据库的CREATE权限。CREATE SCHEMA是CREATE DATABASE的同义词。

An error occurs if the database exists and you did not specify IF NOT EXISTS.

如果数据库存在,而您没有指定if not exists,则会发生错误。

 CREATE_DATEBASE is not permitted within a session that has an active LOCK TABLES statement.

在具有活动LOCK TABLES语句的会话中不允许创建CREATE_DATEBASE。

Each create_option specifies a database characteristic. Database characteristics are stored in the data dictionary.

每个create_option指定一个数据库特征。数据库特征存储在数据字典中。

  • The CHARACTER SET option specifies the default database character set. The COLLATE option specifies the default database collation. For information about character set and collation names, see Chapter 10, Character Sets, Collations, Unicode. CHARACTER SET选项指定默认的数据库字符集。COLLATE选项指定默认的数据库排序规则。有关字符集和排序规则名称的信息,请参见第10章,字符集,排序规则,Unicode。

    To see the available character sets and collations, use the 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”. 要查看可用的字符集和排序规则,请分别使用SHOW character SET和SHOW COLLATION语句。请参见13.7.7.3节“SHOW CHARACTER SET Statement”和13.7.7.4节“SHOW COLLATION Statement”。

  • 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). If the ENCRYPTION option is not specified, the value of the default_table_encryption system variable defines the default database encryption. 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 default_table_encryption setting. For more information, see Defining an Encryption Default for Schemas and General Tablespaces.

  • 在MySQL 8.0.16中引入的ENCRYPTION选项定义了默认的数据库加密,它由数据库中创建的表继承。允许的值是'Y'(启用加密)和'N'(禁用加密)。如果未指定ENCRYPTION选项,则系统变量default_table_encryption的值将定义默认的数据库加密。如果启用了table_encryption_privilege_check系统变量,则需要TABLE_ENCRYPTION_ADMIN特权来指定一个不同于default_table_encryption设置的默认加密设置。有关更多信息,请参见为模式和通用表空间定义加密默认值。

A database in MySQL is implemented as a directory containing files that correspond to tables in the database. Because there are no tables in a database when it is initially created, the CREATE DATABASE statement creates only a directory under the MySQL data directory. Rules for permissible database names are given in Section 9.2, “Schema Object Names”. If a database name contains special characters, the name for the database directory contains encoded versions of those characters as described in Section 9.2.4, “Mapping of Identifiers to File Names”.MySQL中的数据库实现为一个目录,其中包含与数据库中的表相对应的文件。因为最初创建数据库时没有表,所以CREATE database语句只在MySQL数据目录下创建一个目录。允许使用的数据库名称的规则在9.2节“模式对象名称”中给出。如果数据库名称包含特殊字符,则数据库目录的名称包含这些字符的编码版本,如9.2.4节“标识符到文件名的映射”所述。

Creating a database directory by manually creating a directory under the data directory (for example, with mkdir) is unsupported in MySQL 8.0.

在MySQL 8.0中不支持手动在data目录下创建目录(例如使用mkdir)来创建数据库目录。

When you create a database, let the server manage the directory and the files in it. Manipulating database directories and files directly can cause inconsistencies and unexpected results.

当您创建数据库时,让服务器管理目录和其中的文件。直接操作数据库目录和文件可能会导致不一致和意外的结果。

MySQL has no limit on the number of databases. The underlying file system may have a limit on the number of directories.

MySQL对数据库的数量没有限制。底层文件系统可能对目录的数量有限制。

You can also use the mysqladmin program to create databases. See Section 4.5.2, “mysqladmin — A MySQL Server Administration Program”.

您还可以使用mysqladmin程序创建数据库。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值