This topic describes how to create a MaxCompute table.
- Go to the DataStudio page.
- Log on to the DataWorks console.
- In the left-side navigation pane, click Workspaces.
- In the top navigation bar, select the region where your workspace resides, find the workspace, and then click Data Analytics in the Actions column.
- On the Data Development tab, move the pointer over the icon and choose . Alternatively, you can click a workflow in the Business process section, right-click MaxCompute, and then choose .
- In the New table dialog box, set the Table name parameter and click Submit. Notice
- The table name must be 1 to 64 characters in length. It must start with a letter and cannot contain special characters.
- If multiple MaxCompute compute engines are bound to the current workspace, you must select one from the MaxCompute Engine instance drop-down list.
- In the Basic properties section, set the parameters as required.
Parameter Description Chinese name The name of the MaxCompute table. First-level theme The name of the level-1 folder where the table resides.Note Level-1 and level-2 folders show the table locations in DataWorks for you to manage tables more conveniently. Secondary theme The name of the level-2 folder where the table resides. New theme Click New theme to go to the Theme management tab. On this tab, you can create level-1 and level-2 folders for tables.
After you create a folder, click the icon next to New theme to synchronize the folder.
Description The description of the table.
- Create a table. Use one of the following methods to create a table:
- Create a table in DDL mode.
Click DDL mode in the toolbar. In the dialog box that appears, enter the table creation statement and click Generate table structure. Then, parameters in the Physical model design and Table structure design sections are automatically set. For more information about the table creation statement, see the "Create tables" section in Table operations.
- Create a table on the graphical user interface (GUI).
DataWorks allows you to create tables on the GUI.
Section GUI element Description Physical model design Partition type The type of the table. Valid values: Partition Table and Non-partitioned table. Life cycle Specifies whether to enable the lifecycle feature for the table. If you select Life cycle, you must enter a number in the Select lifecycle (days) field. The system automatically deletes data after the data has been stored in the table for the specified period. Hierarchy The layer where the table data is stored or processed. Generally, a data warehouse consists of the operational data store (ODS), common data model (CDM), and application data store (ADS) layers. You can specify a custom name for each layer. Physical classification The category of the table. Tables are categorized into basic services, advanced services, and other services. You can specify a custom name for each category.If you want to create a table category or layer, click New Level to go to the Hierarchical management tab.Note Categories are designed only for your management convenience and do not involve underlying implementation. Table structure design Add Field The button for adding a field. To add a field, click Add Field, configure the field information, and then click the Save icon. Move up The buttons for adjusting the field sequence of the table. If you adjust the sequence of fields in an existing table and then commit the 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 Field name The name of the field. The name can contain letters, digits, and underscores (_). Field Chinese name The display name of the field. Field type The data type of the field. MaxCompute supports the following data types: TINYINT, SMALLINT, INT, BIGINT, FLOAT, DOUBLE, DECIMAL, VARCHAR, CHAR, STRING, BINARY, DATETIME, DATE, TIMESTAMP, BOOLEAN, ARRAY, MAP, and STRUCT. For more information, see Data types. Length/settings The length limit of the field. You must set this parameter if the data type that you specify for the field has a length limit. Description The description of the field. Primary key Specifies whether the field serves as the primary key or part of a composite primary key. Edit icon The icon for editing the field. After you save the field, you can click this icon to edit the field and then click the Save icon to save the edited field. Delete icon The icon for deleting the field.Note If you delete a field from an existing table and then commit the table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment. Partition field designNote This section appears only when you set Partition type to Partition Table in the Physical model design section. Add partition The button for adding a partition. If you set Partition type to Partition Table in the Physical model design section, you must add and configure a partition for the table.
You can click Add partition to add a partition to the current table. If you add a partition to an existing table and then commit the table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment.
Field type The data type of the partition field. We recommend that you use the STRING type for all partition fields. Date partition 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, for example, yyyymmdd or yyyy-mm-dd. Date partition granularity The granularity of the date partition. The granularity can be second, minute, hour, day, month, quarter, or year. You can enter a partition granularity as required. If you want to add multiple partitions with different granularities, note that a greater granularity corresponds to a higher partition level. For example, if you add three partitions whose granularities are day, hour, and month, respectively, to the table, the table contains three partitions: a level-1 partition (month), a level-2 partition (day), and a level-3 partition (hour). Delete icon The icon for deleting the partition. If you delete a partition from an existing table and then commit the table, DataWorks requests you to delete the table and create another table with the same name. This operation is forbidden in the production environment.
- Create a table in DDL mode.
- Click Submit to development environment and Submit to production environment in sequence.If you are using a workspace in basic mode, you need to click Submit to production environment only.
Button Description Load from development environment If the table has been committed to the development environment, this button is clickable. After you click this button, the information about the table you create in the development environment overwrites the table information on the current page.Note This feature is supported only for MaxCompute tables. Submit to development environment Before you click this button, make sure that you have filled in all required parameters on the table configuration tab. You cannot click this button if any parameter is not specified. Load from production environment After you click this button, the information about the table that is committed to the production environment overwrites the table information on the current page.Note This feature is supported only for MaxCompute tables. Submit to production environment After you click this button, the table is created in the workspace of the production environment.