全部产品
阿里云办公

CREATE DATABASE

更新时间:2017-06-07 13:26:11

格式

CREATE DATABASE [IF NOT EXISTS] dbname 
     [create_specification_list];

create_specification_list: 
     create_specification [, create_specification…]

create_specification: 
     [DEFAULT] {CHARACTER SET | CHARSET} [=] charsetname 
     | [DEFAULT] COLLATE [=] collationname
     | REPLICA_NUM [=] num 
     | PRIMARY_ZONE [=] zone

CREATE DATABASE用于创建数据库,并可以指定数据库的默认属性(如数据库默认字符集,校验规则等)。

  • REPLICA_NUM指定副本数,副本数必须与zone的数量相等,默认情况下无需设置;
  • PRIMARY_ZONE指定主zone的名称。

举例

Oceanbase>create database test1 default charset utf8mb4 collate utf8mb4_general_ci replica_num 3 primary_zone ET15SQA_1;
Query OK, 0 rows affected (0.04 sec)

Oceanbase>show create database test1;
+----------+--------------------------------------------------------------------------------------------------+
| Database | Create Database                                                                                  |
+----------+--------------------------------------------------------------------------------------------------+
| test1    | CREATE DATABASE `test1` DEFAULT CHARACTER SET = utf8mb4 REPLICA_NUM = 3 PRIMARY_ZONE = ET15SQA_1 |
+----------+--------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)