Translation: create database statement, createdatabase

Source: Internet
Author: User

Translation: create database statement, createdatabase

This article is the translation of the mariadb official manual: create database.

Original article: https://mariadb.com/kb/en/create-database/
Https://mariadb.com/kb/zh-cn/create-database/ I submitted to the MariaDB official manual

Syntax
CREATE [OR REPLACE] {DATABASE | SCHEMA} [IF NOT EXISTS] db_name    [create_specification] ...create_specification:    [DEFAULT] CHARACTER SET [=] charset_name  | [DEFAULT] COLLATE [=] collation_name
Description

Create database creates a DATABASE with a given name. This statement requires the CREATE permission on the database. Create schema is a synonym for create database. IF the if not exists clause is used, a warning message is returned instead of an error when the database already EXISTS.

OR REPLACE

MariaDB starting with 10.1.3 introduces the or replace clause in MariaDB 10.1.3. If an optional or replace clause is used, it is short 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, when the specified database already EXISTS, MariaDB returns a warning instead of an error message.

Example
CREATE DATABASE db1;Query OK, 1 row affected (0.18 sec)CREATE DATABASE db1;ERROR 1007 (HY000): Can't create database 'db1'; database existsCREATE 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 |+-------+------+----------------------------------------------+

Set character sets and sorting rules. For more information, see set character sets and sorting rules.

CREATE DATABASE czech_slovak_names   CHARACTER SET = 'keybcs2'  COLLATE = 'keybcs2_bin';
Go back to the Linux series article outline: workshop!

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.