Creating a Database or a Table
Definition of Database and Table in DLI
A database, built on the computer storage device, is a data warehouse where data is organized, stored, and managed based on its structure.
The table is an important part of the database. It consists of rows and columns. Each column functions as a field. Each value in a field (column) represents a type of data.
The database is a framework and the table contains data content. A database has one or more tables.
You can create databases and tables on the management console or using SQL statements. This section describes how to create a database and a table on the management console.
For details about using SQL statements, see Creating a Database, Creating an OBS Table, and Creating a DLI Table.
A view can be created only by using SQL statements. You cannot create a view on the Create Table page.
Precautions
- If a folder and a file have the same name in the OBS directory, the file path is preferred as the path of the OBS table to be created.
- When creating a database or table, you need to grant permissions to other users so that they can view the created database or table. For details, see Common Operations Supported by DLI System Policy.
Creating a Database
- You can create a database on either the Data Management page or the SQL Editor page.
- To create a database on the Data Management page:
- On the left of the management console, choose Data Management > Databases and Tables.
- In the upper right corner of the Databases and Tables page, click Create Database to create a database.
- To create a database on the SQL Editor page:
- On the left of the management console, click SQL Editor.
- In the navigation pane on the left, click next to Databases.
- To create a database on the Data Management page:
- In the displayed Create Database dialog box, specify Name and Description by referring to Table 1.
Figure 1 Creating a database
Table 1 Description Parameter
Description
Database Name
- Only numbers, letters, and underscores (_) are allowed. The value cannot contain only numbers or start with an underscore (_).
- The database name is case insensitive and cannot be left blank.
- The value can contain a maximum of 128 characters.
NOTE:The default database is a built-in database. You cannot create the default. database.
Enterprise Project
If the created queue belongs to an enterprise project, you can select the corresponding enterprise project.
Enterprise projects let you manage cloud resources and users by project.
For details about how to set enterprise projects, see Enterprise Management User Guide.
NOTE:This parameter is displayed only for users who have enabled the Enterprise Management Service.
Description
Description of a database.
Tags
Tags used to identify cloud resources. A tag includes the tag key and tag value. If you want to use the same tag to identify multiple cloud resources, that is, to select the same tag from the drop-down list box for all services, you are advised to create predefined tags on the Tag Management Service (TMS).
For details, see Tag Management Service User Guide.
NOTE:- A maximum of 20 tags can be added.
- Only one tag value can be added to a tag key.
- The key name in each resource must be unique.
- Tag key: Enter a tag key name in the text box.
NOTE:
A tag key can contain a maximum of 128 characters. Only letters, numbers, spaces, and special characters (_.:=+-@) are allowed, but the value cannot start or end with a space or start with _sys_.
- Tag value: Enter a tag value in the text box.
NOTE:
A tag value can contain a maximum of 255 characters. Only letters, numbers, spaces, and special characters (_.:=+-@) are allowed. The value cannot start or end with a space.
- Click OK.
After a database is created, you can view and select the database for use on the Databases and Tables page or SQL Editor page.
Creating a Table
Before creating a table, ensure that a database has been created.
- You can create a table on either the Databases and Tables page or the SQL Editor page.
Datasource connection tables, such as View tables, HBase (CloudTable/MRS) tables, OpenTSDB (CloudTable/MRS) tables, GaussDB(DWS) tables, RDS tables, and CSS tables, cannot be created. You can use SQL to create views and datasource connection tables. For details, see sections Creating a View and Creating a Datasource Connection Table in the Data Lake Insight SQL Syntax Reference.
- To create a table on the Data Management page:
- On the left of the management console, choose Data Management > Databases and Tables.
- On the Databases and Tables page, select the database for which you want to create a table. In the Operation column, click More > Create Table to create a table in the current database.
- To create a table on the SQL Editor page:
- On the left of the management console, click SQL Editor.
- In the navigation pane of the displayed SQL Editor page, click Databases. You can create a table in either of the following ways:
- Click a database name. In the Tables area, click on the right to create a table in the current database.
- Click on the right of the database and choose Create Table from the shortcut menu to create a table in the current database.
- To create a table on the Data Management page:
- In the displayed Create Table dialog box, set parameters as required.
- If you set Data Location to DLI, set related parameters by referring to Table 2.
Figure 2 Creating a DLI table
- If you set Data Location to OBS, set related parameters by referring to Table 2 and Table 3.
Figure 3 Creating an OBS table
Table 2 Common parameters Parameter
Description
Example
Table Name
- Only numbers, letters, and underscores (_) are allowed. The value cannot contain only numbers or start with an underscore (_).
- The table name is case insensitive and cannot be left unspecified.
- The table name can contain the dollar sign ($). An example value is $test.
- The value can contain a maximum of 128 characters.
table01
Data Location
Data storage location. Currently, DLI and OBS are supported.
DLI
Description
Description of the table.
-
Column Type
Available values: Normal or Partition
Normal
Column
Name of a column in a table. The column name must contain at least one letter and can contain underscores (_). It cannot contain only numbers.
You can select Normal or Partition. Partition columns are dedicated to partition tables. User data is partitioned to improve query efficiency.
NOTE:The column name is case-insensitive and must be unique.
name
Type
Data type of a column. This parameter corresponds to Column Name.
- string: The data is of the string type.
- int: Each integer is stored on four bytes.
- date: The value ranges from 0000-01-01 to 9999-12-31.
- double: Each number is stored on eight bytes.
- boolean: Each value is stored on one byte.
- decimal: The valid bits are positive integers between 1 to 38, including 1 and 38. The decimal digits are integers less than 10.
- smallint/short: The number is stored on two bytes.
- bigint/long: The number is stored on eight bytes.
- timestamp: The data indicates a date and time. The value can be accurate to six decimal points.
- float: Each number is stored on four bytes.
- tinyint: Each number is stored on one byte. Only OBS tables support this data type.
string
Column Description
Description of a column.
-
Operation
- Add Column
- Delete
NOTE:
If the table to be created includes a great number of columns, you are advised to use SQL statements to create the table or import column information from the local EXCEL file.
-
Table 3 Parameter description when Data Location is set to OBS Parameter
Description
Example
Data Format
DLI supports the following data formats:
- Parquet: DLI can read non-compressed data or data that is compressed using Snappy and gzip.
- CSV: DLI can read non-compressed data or data that is compressed using gzip.
- ORC: DLI can read non-compressed data or data that is compressed using Snappy.
- JSON: DLI can read non-compressed data or data that is compressed using gzip.
- Avro: DLI can read uncompressed Avro data.
CSV
Storage Path
Enter or select an OBS path. The path can be a folder or a path.
NOTE:If you need to import data stored in OBS to the OBS table, set this parameter to the path of a folder. If the table creation path is a file, data fails to be imported.
obs://obs1/sampledata.csv
Table Header: No/Yes
This parameter is valid only when Data Format is set to CSV. Whether the data source to be imported contains the table header.
Click Advanced Settings and select the checkbox next to Table Header: No. If the checkbox is selected, the table header is displayed. If the checkbox is deselected, no table header is displayed.
-
User-defined Delimiter
This parameter is valid only when Data Format is set to CSV and you select User-defined Delimiter.
The following delimiters are supported:
- Comma (,)
- Vertical bar (|)
- Tab character (\t)
- Others: Enter a user-defined delimiter.
Comma (,)
User-defined Quotation Character
This parameter is valid only when Data Format is set to CSV and you select User-defined Quotation Character.
The following quotation characters are supported:
- Single quotation mark (')
- Double quotation marks (")
- Others: Enter a user-defined quotation character.
Single quotation mark (')
User-defined Escape Character
This parameter is valid only when Data Format is set to CSV and you select User-defined Escape Character.
The following escape characters are supported:
- Backslash (\)
- Others: Enter a user-defined escape character.
Backslash (\)
Date Format
This parameter is valid only when Data Format is set to CSV or JSON.
This parameter specifies the format of the date in the table and is valid only Advanced Settings is selected. The default value is yyyy-MM-dd. For definition of characters involved in the date pattern, see Table 3 in Importing Data to the Table.
2000-01-01
Timestamp Format
This parameter is valid only when Data Format is set to CSV or JSON.
This parameter specifies the format of the timestamp in the table and is valid only Advanced Settings is selected. The default value is yyyy-MM-dd HH:mm:ss. For definition of characters involved in the time pattern, see Table 3 in Importing Data to the Table.
2000-01-01 09:00:00
- If you set Data Location to DLI, set related parameters by referring to Table 2.
- Click OK.
After a table is created, you can view and select the table for use on the Data Management page or SQL Editor page.
- (Optional) After a DLI table is created, you can decide whether to directly import data to the table.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.