Create tables

Last Updated: Dec 08, 2017

Generally, you need to create tables during data development to store the results of data synchronization and data processing. The Data Management module of Alibaba Cloud DTplus platform provides two ways to create a table:

  • Visualized table creation
  • Statement-based table creation

Compared with the script-based table creation by using the Data Development module, tables created by using the Data Management module can be classified into different business categories. The classification can facilitate metadata management for numerous businesses in the organization.

Prepare for permissions (prerequisite)

Real-name registration for cloud accounts to generate the access ID and AccessKey. The cloud account used to create tables is the current logon account and must have an access ID and AccessKey to send the table creation request to MaxCompute. Therefore, this cloud account must complete the real-name registration to generate the access ID and AccessKey.

  1. Log on to Alibaba Cloud official website using the cloud account.

  2. Go to My Center, and click accesskeys at the upper right corner to enter the new page, as shown in the following figure:

    1

  3. Click Create Access Key to apply for an access ID and AccessKey successfully.

    1

Grant table creation permission to cloud accounts. You must grant permissions to the cloud account who is about to create tables. MaxCompute project owners can directly run the authorization statement to authorize the permissions.

  1. use projectname; --Open the project space
  2. add user aliyun$Cloud account; --Add a user
  3. grant CreateInstance,CreateTable,List ON PROJECT projectname TO aliyun$Cloud account; --Grant permissions to the user

Note: The tables are created using the current logon cloud account, so the table owner is the current logon account.

Visualized table creation

  1. Navigate to DataWorks > management console as a developer. Click Enter the work area after the corresponding project.

  2. Click Data Management in the top navigation bar and navigate to Manage Data Tables page.

  3. Click Create table.

    1

  4. Complete the configurations of the Basic information step in the Create table dialog box.

    1

    • Project name: The list shows the MaxCompute project space that the current logon user is in.

    • Table name: A table name consists of letters, numbers, and underscores.

    • Alias: The Chinese name of the table.

    • Category: The category of the current table. Up to four levels of category are supported. For more information about the configuration of category navigation, see Manage configuration.

    • Description: A brief description of the current table.

    • Lifecycle: The Lifecycle function of MaxCompute. Enter a number to represent the number of days. Data in the table (or partition) that has not been updated within the specified number of days will be cleared. Five options are available, including 1 day, 7 days, 32 days, Permanent, and User-defined.

  5. Click Next.

  6. Complete the configurations of the Field and partition information step in the Create table dialog box.

    • Complete the field information settings.

    • Set the partition.

    1

    • Field’s English name: The English name of a field, which consists of letters, numbers, and underscores.

    • Field type: MaxCompute data type (string, bigint, double, datetime, or boolean).

    • Description: The detailed description of a field.

    • Operation: The options include Move Up, Move Down, and Delete.

    • Set a partition: If Yes is selected, configure the partition key information. The string and bigint types are supported.

  7. Click Submit.

After the newly created table is submitted, the system automatically goes back to the Manage Data Tables page. Click My managed tables to view the newly created table.

Statement-based table creation

  1. Navigate to Alibaba Cloud DTplus platform > DataWorks > management console as a developer, and click Enter the work area in the action bar of the corresponding project.

  2. Click Data Management in the top navigation bar and navigate to the Manage Data Tables page.

  3. Click Create table.

  4. Click DDL table creation.

  5. Enter the MaxCompute SQL statements of table creation as follows:

    1

    1. create table if not exists table2
    2. (
    3. id string commentUser ID’,
    4. name string commentUsername
    5. ) partitioned by(dt string)
    6. LIFECYCLE 7;
  6. Click Submit. The Basic information step appears.

    1

    Except Alias, Category, and Lifecycle, all the other configurations in the Basic information step are automatically filled in. You need to edit and provide the Chinese names and the security levels of fields in the Field and partition information step.

    1

  7. Complete the configurations in the Basic information step of the newly created table.

    1

  8. Click Next.

  9. Click Submit.

After the newly created table is submitted, the system automatically goes back to the Manage Data Tables page. Click My managed tables to view the newly created table.

Thank you! We've received your feedback.