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 the workspace that you want to manage resides. Find the workspace and click DataStudio in the Actions column.
- On the page that appears, move the pointer over the icon and choose . Alternatively, you can click the desired workflow in the Business Flow section, right-click MaxCompute, and then select Create Table.
- In the Create table dialog box, select a path from the Path drop-down list, configure the Name parameter, and then click Create. Notice
- The table name can be a maximum of 100 characters in length. The table name must start with a letter and cannot contain special characters.
- If multiple MaxCompute compute engine instances are associated with the current workspace, you must select one from the Engine Instance drop-down list.
- In the General section, configure the parameters.
Parameter Description Display Name The name of the MaxCompute table. Level-1 Folder The name of the level-1 folder where the table resides.Note The level-1 and level-2 folders show the table locations in DataWorks for you to manage tables with ease. 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 tab of the Table Management tab. On the Folder Management tab, you can create level-1 and level-2 folders for tables.
After you create a folder, click next to Create Folder to synchronize the folder.
Description The description of the table.
- Create a table. You can use one of the following methods to create a table:
- Create a table by using a DDL statement.
Click DDL Statement in the toolbar. In the dialog box that appears, enter the table creation statement and click Generate Table Schema. Then, parameters in the Physical Model and Schema sections are automatically configured. For more information about the table creation statement, see the "Create a table" section in Table operations.
- Create a table on the graphical user interface (GUI).
DataWorks allows you to create tables on the GUI.
Category Parameter Description Physical model design Partitioning Valid values: Partitioned Table and Non-Partitioned Table. Time-to-Live Specifies whether to enable the Time-to-Live feature for the table. If you enable the Time-to-Live feature, you must enter a number in the TTL (Days) field. If the table or partition is stored for more than the specified number of days, data that has not been updated is deleted. Layer The layer where the table data is stored or processed. A data warehouse consists of the operational data store (ODS), common data model (CDM), and application data store (ADS) layers. You can customize a name for each layer. Category The category of the table. Tables are categorized into basic services, advanced services, and other services. You can customize a name for each category.If you want to create a table category or layer, click Create Level. On the Table Management tab, click the Level Management tab.Note Categories are designed only to help you manage the table and do not affect underlying implementation. Schema design Create Field The button for adding a field. To add a field, click Create Field, configure the field information, and then click the save icon in the Actions column. Move Up The buttons for adjusting the field sequence of the table. If you want to adjust the sequence of fields in an existing table, you must delete the table and create another table with the same name. These operations are forbidden in the production environment. Move Down Field Name The name of the field. The name can contain letters, digits, and underscores (_). Display Name The display name of the field. Data 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. Definition or Maximum Value Length The length limit of the field. You must configure this parameter if the data type that you specify for the field has a length limit. Description The description of the field. Primary Key Field 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 want to delete a field from an existing table and then commit the table, you must delete the table and create another table with the same name. These operations are forbidden in the production environment. Partition field designNote This section appears only when you set Partitioning to Partitioned Table in the Physical Model section. Add The button for adding a partition. If you set the Partitioning parameter to Partitioned Table in the Physical Model section, you must configure a partition for the table.
You can add a partition to the current table. If you want to add a partition to an existing table and then commit the table, you must delete the table and create another table with the same name. These operations are forbidden in the production environment.
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 yyyymmdd or yyyy-mm-dd. Partition Column Date 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 based on your business requirements. 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 want to delete a partition from an existing table and then commit the table, you must delete the table and create another table with the same name. These operations are forbidden in the production environment.
- Create a table by using a DDL statement.
- Click Commit to Development Environment and Commit to Production Environment in sequence. If you are using a workspace in basic mode, you need only to click Commit to Production Environment.
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. Commit to Development Environment Before you click this button, make sure that you have configured all required parameters on the current page. You cannot click this button if any parameter is not configured. 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. Commit to Production Environment After you click this button, the table is created in the workspace of the production environment.