This topic describes how to create a table.

Prerequisites

The MaxCompute module is available on the DataStudio page only after you bind a MaxCompute computing engine to the current workspace on the Workspace Management page. For more information, see Configure a workspace.

Procedure

  1. Log on to the DataWorks console. In the left-side navigation pane, click Workspaces. On the Workspaces page, find the target workspace and click Data Analytics in the Actions column.
  2. Move the pointer over the Create icon and choose MaxCompute > Table.
    You can also find the target workflow, right-click MaxCompute, and choose Create > Table.
  3. In the Create Table dialog box that appears, enter the table name and click Commit.
  4. Configure the basic properties of the table.
    Parameter or button Description
    Display Name The alias of the table.
    Level 1 Folder The name of the level-1 folder where the table resides.
    Note Level-1 and level-2 folders only show the table locations in DataWorks so that you can better manage tables.
    Level 2 Folder The name of the level-2 folder where the table resides.
    Create Folder Click Create Folder to go to the Folder Management page. On this page, you can create level-1 and level-2 folders for tables.
    Description The description of the table.
  5. Create a table.
    Use one of the following methods to create a table:
    • Create a table in DDL mode.

      Click DDL Statement in the top navigation bar. In the dialog box that appears, enter standard statements for creating a table.

      After you finish editing the statements, click Generate Table Schema. Information is automatically entered in the Basic Information, Physical Model, and Schema sections.

    • Create a table on the graphical user interface (GUI).
      If the DDL mode is inappropriate for you to create a table, try using the GUI. The following table describes the relevant parameters for creating a table on the GUI.
      Section Parameter or button Description
      Physical Model Partitioning Specifies whether the table is partitioned. Valid values: Partitioned Table and Non-Partitioned Table.
      Time-to-Live The time-to-live of data in MaxCompute. The entered number indicates the number of days. Data in a table (or partition) that has not been updated in the specified number of days is automatically cleared.
      Table Level The level of the table. Generally, tables are divided into operation data store (ODS), common data model (CDM), and application data service (ADS) levels. You can specify a custom level name.
      Categories The category of the table. Tables are categorized into basic services, advanced services, and other services. You can specify a custom category name.
      If you want to create a table category or level, click Create Level to go to the Level Management page.
      Note Categories are designed only for your management convenience and do not involve underlying implementation.
      Schema Field Name The name of the field. A field name can contain letters, digits, and underscores (_).
      Display Name The alias of the field.
      Data Type The MaxCompute data type of the field. Currently, DataWorks supports only the data of STRING, BIGINT, DOUBLE, DATETIME, and BOOLEAN types. For more information, see Data types.
      Description The detailed description of the field.
      Primary Key Field Specifies whether the field serves as the primary key or part of a composite primary key.
      Create Field Adds a field to the table.
      Delete Deletes a created field.
      Note If you delete a field from an existing table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment.
      Move Up Adjusts the field sequence of a table that has not been created. If you adjust the sequence of fields in an existing table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment.
      Move Down The description is the same as that of the Move Up operation.
      Add Adds a partition to the current table. If you add a partition to an existing table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment.
      Delete Deletes a partition from the current table. If you delete a partition from an existing table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment.
      Actions Commits a partition or deletes a partition.
      Partition Field Design
      Note This section is available only when Partitioning under Physical Model is set to Partitioned Table.
      Data Type The data type of the partition field. We recommend that you use the STRING type for all partition fields.
      Partition Column Date Format The format of the date partition. If the partition field is a date (although the data type may be STRING), select or enter a date format, such as yyyymmmdd or yyyy-mm-dd.
      Partition Column Date Granularity The granularity of the date partition. Valid values: Second, Minute, Hour, Day, Month, Quarter, and Year. You can enter a partition granularity as required. If you want to specify multiple partition granularities, note that a greater granularity corresponds to a higher partition level by default. For example, three partitions whose granularities are day, hour, and month, respectively, are available. The multi-level partition hierarchy is as follows: level-1 partition (month), level-2 partition (day), and level-3 partition (hour).

What to do next

After the table is created, you can commit the table, modify the table, and query the table data. For more information, see Table.