In this topic, the created tables bank_data and result_table are used as an example for creating a table and uploading data. The bank_data table stores business data, while the result_table stores data analysis results.
- After Create Workspace , click Enter workspacein the corresponding project.
- Go to the Data Studio (original data development) page and select .
- Enter the table name in the new table dialog box.
- Click Submit.
- Enter the new table page, and select the DDL mode.
- Enter the table creation statement in the DDL schema dialog box, and click build table structure.
For more SQL syntax for creating tables, see creating/viewing/deleting tables.
The statements used for table creation in this example are as follows:
CREATE TABLE IF NOT EXISTS bank_data ( age BIGINT COMMENT 'age', job STRING COMMENT 'job type', marital STRING COMMENT 'marital status', education STRING COMMENT 'educational level', default STRING COMMENT 'credit card ownership', housing STRING COMMENT 'mortgage', loan STRING COMMENT 'loan', contact STRING COMMENT 'contact information', month STRING COMMENT 'month', day_of_week STRING COMMENT 'day of the week', duration STRING COMMENT 'Duration', campaign BIGINT COMMENT 'contact times during the campaign', pdays DOUBLE COMMENT 'time interval from the last contact', previous DOUBLE COMMENT 'previous contact times with the customer', poutcome STRING COMMENT 'marketing result', 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 'has time deposit or not' );
- After the table structure is generated, enter the table name and click Submit to Production Environment.
- You can search the created table by entering the table name in the left-hand navigation table management to view the table information.
- Go to the DataStudio page and select .
- Enter the table name in the new table dialog box and click Submit.
- Enter the new table page and select DDL mode.
- Enter the build TABLE statement in the DDL schema dialog box, and click build table structure. The following is a create table example:
CREATE TABLE IF NOT EXISTS result_table ( education STRING COMMENT 'educational level', num BIGINT COMMENT 'number of people' );
- You can search the created table by the table name in the left-hand navigation table management and view table information.
Upload local data to bank_data
- Uploading data in locally stored text files to the workspace table.
- Using data integration to import business data from various data sources to the workspace.
- File type: Only .txt and .csv files are supported.
- File Size: Not exceeding 10 M.
- Operation objects: Partition and non-partition tables can be imported, but Chinese partition values are not supported.
- Click Import to select import local data.
- Select a local data file, configure the import information, and click Next,
- Enter at least two letters to search the table by name. Select the table for the data to be imported, for example, bank_data.
- Select the field matching method ("Match by Position" used in this example) and click Import ,
After the file is imported, the system returns the number of lines that were successful in the data import or an exception that failed.
Other data import methods
- Create a Data Synchronization task
This method applies to saving RDS, MySQL, SQL Server, PostgreSQL, MaxCompute, OSS, DRDs, OSS data from a variety of data sources, such as, Oracle, FTP, DM, HDFS, and MongoDB.
For details on creating data synchronization tasks with DataWorks, see creating a data synchronization task.
- Local file uploads
This file upload method is suitable for .txt and .csv files smaller than 10M , and the target supports both partition and non-partition tables , but does not support Chinese partition.
For DataWorks local file upload, see preceding local data upload to bank_data for details.
- Upload files using the tunnel command
This method applies to local files and other resource files greater than 10M in size.
Upload and download the data through tunnel commands provided by the MaxCompute client, when local data files need to be uploaded to the partition table, so they can be uploaded using the client tunnel command. See Tunnel command actions for details.
You have learned how to create a table and upload data now. You can go to the next topic, which will show you how to create a work flow for further data analysis and project space computing . For more information, see creating a workflow.