This topic takes the bank_data and result_table tables as an example to describe how to create tables and import data in the DataWorks console.

Prerequisites

A MaxCompute compute engine is bound to the workspace where you want to create tables. The MaxCompute service is available in a workspace only after you bind a MaxCompute compute engine to the workspace on the Workspace Management page. For more information, see Configure a workspace.

Background information

The bank_data table stores business data and the result_table table stores data analytics results.

Create the bank_data table

  1. Go to the DataStudio page.
    1. Log on to the DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. In the top navigation bar, select the region where your workspace resides, find the workspace, and then click Data Analytics in the Actions column.
  2. On the Data Development tab, move the pointer over the Create icon icon and choose MaxCompute > Table.
    Alternatively, you can click a workflow in the Business process section, right-click MaxCompute, and then choose New > Table.
  3. In the New table dialog box, set Table name to bank_data 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 Please select an Engine type drop-down list.
  4. On the table configuration tab, click DDL mode.
  5. In the DDL mode dialog box, enter the following statement and click Generate table structure:
    CREATE TABLE IF NOT EXISTS bank_data
    (
     age             BIGINT COMMENT 'age',
     job             STRING COMMENT 'job type',
     marital         STRING COMMENT 'marital status',
     education       STRING COMMENT 'education level',
     default         STRING COMMENT 'credit card',
     housing         STRING COMMENT 'mortgage',
     loan            STRING COMMENT 'loan',
     contact         STRING COMMENT 'contact',
     month           STRING COMMENT 'month',
     day_of_week     STRING COMMENT 'day in a week',
     duration        STRING COMMENT 'duration',
     campaign        BIGINT COMMENT 'number of contacts during the campaign',
     pdays           DOUBLE COMMENT 'interval from the last contact',
     previous        DOUBLE COMMENT 'number of contacts with the customer',
     poutcome        STRING COMMENT 'result of the previous marketing campaign',
     emp_var_rate    DOUBLE COMMENT 'employment change rate',
     cons_price_idx  DOUBLE COMMENT 'consumer price index',
     cons_conf_idx   DOUBLE COMMENT 'consumer confidence index',
     euribor3m       DOUBLE COMMENT 'euro deposit rate',
     nr_employed     DOUBLE COMMENT 'number of employees',
     y               BIGINT COMMENT 'whether time deposit is available'
    );

    For more information about the SQL syntax for creating tables, see Create and view a table.

  6. In the Confirm operation message, click OK.
  7. Set the Chinese name parameter in the Basic properties section and click Submit to development environment and Submit to production environment.
    Note This topic uses a workspace in standard mode as an example. If you are using a workspace in basic mode, you only need to click Submit to production environment.
  8. In the left-side navigation submenu, click the Table Management icon.
  9. On the Table Management tab, double-click the name of the created table to view the table information.

Create the result_table table

  1. On the Data Development tab, move the pointer over the Create icon icon and choose MaxCompute > Table.
    Alternatively, you can click a workflow in the Business process section, right-click MaxCompute, and then choose New > Table.
  2. In the New table dialog box, set Table name to result_table and click Submit.
  3. On the table configuration tab, click DDL mode. In the DDL mode dialog box, enter the following statement and click Generate table structure:
    CREATE TABLE IF NOT EXISTS result_table
    (  
     education   STRING COMMENT 'education level',
     num         BIGINT COMMENT 'number of people'
    );
  4. In the Confirm operation message, click OK.
  5. Set the Chinese name parameter in the Basic properties section and click Submit to development environment and Submit to production environment.
  6. In the left-side navigation submenu, click the Table Management icon.
  7. On the Table Management tab, double-click the name of the created table to view the table information.

Upload a local file to import its data to the bank_data table

You can perform the following operations in the DataWorks console:
  • Upload a local text file to import its data to a table in a workspace.
  • Use Data Integration to import business data from different data stores to a workspace.
Note Comply with the following rules when you upload a local file:
  • File format: The file must be in the .txt, .csv, or .log format.
  • File size: The size of the file cannot exceed 30 MB.
  • Destination object: The destination object can be a partitioned table or a non-partitioned table. The partition key value cannot be in Chinese.

To upload the local file banking.txt to DataWorks, perform the following steps:

  1. Click the Import icon icon on the Data Development tab.
  2. In the Data import wizard dialog box, enter at least three letters to search for tables, select the table to which you want to import data, and then click Next Step.
  3. In the dialog box that appears, set the Select data import method parameter to Upload local files and click Browse next to Select File. Select the local file that you want to upload and specify other parameters.
    bank
    Parameter Description
    Select data import method The method of importing data. Default value: Upload local files.
    Select File The file to upload. To upload a file, click Browse and select the local file to upload.
    Select separator The delimiter of fields in the file. Valid values: Comma, Tab, SEMICOLON, Space, |, #, and &. In this example, select Comma.
    Original character set The character set of the file. Valid values: GBK, UTF-8, CP936, and ISO-8859. In this example, select GBK.
    Import start row The row from which data is to be imported. In this example, select 1.
    First behavior title Specifies whether to use the first row as the header row. In this example, do not select First behavior title.
    Data preview The preview of the data to be imported.
    Note If the data volume is large, only the data in the first 100 rows and 50 columns appears.
  4. Click Next Step.
  5. Select a matching mode for the fields in the source file and destination table. In this example, select Match by location.
  6. Click Import data.

What to do next

Now you have learned how to create tables and import data. You can proceed with the next tutorial. In the next tutorial, you will learn how to create, configure, and commit a workflow and then use the Data Analytics feature to further compute and analyze data in the workspace. For more information, see Create a workflow.