CREATE DATABASE
Descriptionβ
This statement is used to create a new database
Syntaxβ
CREATE DATABASE [IF NOT EXISTS] <db_name>
[PROPERTIES ("<key>"="<value>"[, ... ])];
Required parametersβ
** 1. <db_name>
**
Database Name
Optional parametersβ
** 1. <PROPERTIES>
**
Additional information about this database
Permission Controlβ
The user executing this SQL command must have at least the following permissions:
Permissions | Object | Notes |
---|---|---|
CREATE_PRIV | Corresponding database | You need to have the create permission for the corresponding database |
Precautionsβ
If you want to specify the default replica distribution strategy for the table under db, you need to specify <replication_allocation>
(the <replication_allocation>
attribute of table has a higher priority than db):
PROPERTIES (
"replication_allocation" = "tag.location.default:3"
)
Exampleβ
-
Create a new database db_test
CREATE DATABASE db_test;
-
Create a new database and set the default replica distribution:
CREATE DATABASE `db_test`
PROPERTIES (
"replication_allocation" = "tag.location.group_1:3"
);