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.

Background information

The bank_data table stores business data, whereas 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 the target workspace resides. Find the target workspace and click Data Analytics in the Actions column.
  2. On the DataStudio page, move the pointer over Create and choose MaxCompute > Table.
    You can also find the target workflow, right-click MaxCompute, and then choose Create > Table.
  3. In the Create Table dialog box that appears, set Table Name to bank_data and click Commit.
    Notice
    • The table name can be up to 64 characters in length. The table name must start with a letter and cannot contain Chinese or special characters.
    • If multiple MaxCompute computing 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 editing page, click DDL Statement.
  5. In the DDL Statement dialog box that appears, enter the following statement and click Generate Table Schema:
    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 message that appears, click OK.
  7. Set the Display Name parameter in the General section and click Commit in Development Environment and Commit to Production Environment.
    Note This topic uses a workspace in the standard mode as an example. If you are using a workspace in the basic mode, you only need to click Commit to Production Environment.
  8. In the left-side navigation submenu, click the Workspace Tables icon.
  9. On the Workspace Tables tab that appears, double-click the name of the created table to view the table information.

Create the result_table table

  1. On the DataStudio page, move the pointer over Create and choose MaxCompute > Table.
    You can also find the target workflow, right-click MaxCompute, and then choose Create > Table.
  2. In the Create Table dialog box that appears, set Table Name to result_table and click Commit.
  3. Click DDL Statement. In the dialog box that appears, enter the following statement and click Generate Table Schema:
    CREATE TABLE IF NOT EXISTS result_table
    (  
     education       STRING COMMENT 'education level',
     num         BIGINT COMMENT 'number of people'
    );
  4. In the message that appears, click OK.
  5. Set the Display Name parameter in the General section and click Commit in Development Environment and Commit to Production Environment.
  6. In the left-side navigation submenu, click the Workspace Tables icon.
  7. On the Workspace Tables tab that appears, 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, follow these steps:

  1. Click Import on the DataStudio page.
  2. In the Data Import Wizard dialog box that appears, enter at least three letters to search for tables, select the table to which you want to import data, and then click Next.
  3. In the dialog box that appears, set the Select Data Import Method parameter to Upload Local File and click Browse next to Select File. Select the local file and set the remaining parameters as required.
    GUI Element Description
    Select Data Import Method The method of importing data. Default value: Upload Local File.
    Select File The file to be uploaded. To upload a file, click Browse and select the local file to upload.
    Select Delimiter 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 First Row The row from which data is to be imported. In this example, select 1.
    First Row as Field Names Specifies whether to use the first row as the header row. In this example, do not select First Row as Field Names.
    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.
  5. Select a matching mode for the fields in the source file and destination table. In this example, select 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.