This is the Official Handbook for MARIADB: The translation of CREATE database.
Original:https://mariadb.com/kb/en/create-database/
I submit it to MARIADB official manual:https://mariadb.com/kb/zh-cn/create-database/
Grammar
CREATE [OR REPLACE] {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [create_specification] ...create_specification: [DEFAULT] CHARACTER SET [=] charset_name | [DEFAULT] COLLATE [=] collation_name
Describe
Create database creates a db of the given name. This statement requires create permission on database. The CREATE schema is a synonym for create database. If the IF NOT EXISTS clause is used, a warning information is returned instead of returning an error when the database already exists.
OR REPLACE
MariaDB starting with 10.1.3 introduced an OR replace clause in the MariaDB 10.1.3. If an optional or replace clause is used, it is shorthand for the following statement:
DROP DATABASE IF EXISTS db_name;CREATE DATABASE db_name ...;
IF not EXISTS
When the IF NOT EXISTS clause is used, MARIADB returns a warning instead of an error message when the specified database already exists.
Example
CREATE DATABASE db1;Query OK, 1 row affected (0.18 sec) CREATE DATABASE db1;ERROR 1007 (HY000): Can ' t Create database ' db1 ';Database exists CREATE OR REPLACE DATABASE db1;Query OK, 2 rows Affected (0.00 sec) CREATE DATABASE IF not EXISTS db1;Query OK, 1 row affected, 1 warning (0.01 sec) SHOW WARNINGS;+-------+------+----------------------------------------------+| Level | Code | Message |+-------+------+----------------------------------------------+| Note | 1007 | Can ' t Create database ' db1 ';Database exists |+-------+------+----------------------------------------------+
Sets the character set and collation. For more information , see Setting character sets and sorting rules .
CREATE DATABASE czech_slovak_names CHARACTER SET = ‘keybcs2‘ COLLATE = ‘keybcs2_bin‘;
back to Linux series article outline: http://www.cnblogs.com/f-ck-need-u/p/7048359.htmlback to Database series article outline: http://www.cnblogs.com/f-ck-need-u/p/7586194.htmlReprint Please specify Source: http://www.cnblogs.com/f-ck-need-u/p/7599521.htmlNote: If you think this article is not bad please click on the lower right corner of the recommendation, your support can inspire the author more enthusiasm for writing, thank you very much!
Translation: CREATE database statement