Creating a Database
Function
This statement is used to create a database.
Syntax
1 2 3 |
CREATE [DATABASE | SCHEMA] [IF NOT EXISTS] db_name [COMMENT db_comment] [WITH DBPROPERTIES (property_name=property_value, ...)]; |
Keywords
- IF NOT EXISTS: Prevents system errors if the database to be created exists.
- COMMENT: Describes a database.
- DBPROPERTIES: Specifies database attributes. The attribute name and attribute value appear in pairs.
Parameters
Parameter |
Description |
---|---|
db_name |
Database name, which consists of letters, digits, and underscores (_). The value cannot contain only digits or start with a digit or underscore (_). |
db_comment |
Database description |
property_name |
Database property name |
property_value |
Database property value |
Precautions
- DATABASE and SCHEMA can be used interchangeably. You are advised to use DATABASE.
- The default database is a built-in database. You cannot create a database named default.
Example
For details about the complete process for submitting SQL jobs, see Submitting a SQL Job..
- Create a queue. A queue is the basis for using DLI. Before executing SQL statements, you need to create a queue. For details, see Creating a Queue.
- On the DLI management console, click SQL Editor in the navigation pane on the left. The SQL Editor page is displayed.
- In the editing window on the right of the SQL Editor page, enter the following SQL statement for creating a database and click Execute. Read and agree to the privacy agreement, and click OK.
If database testdb does not exist, run the following statement to create database testdb:
1
CREATE DATABASE IF NOT EXISTS testdb;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot