All Products
Search
Document Center

Create a MySQL table and read data from the table

Last Updated: Apr 24, 2019

Create a MySQL table

In DMS for Data Lake Analytics, run the following SQL statement to create a table named tbl_person for the person table in the user-created ECS-based MySQL database.

  1. CREATE EXTERNAL TABLE hello_mysql_vpc_rds.tbl_person (
  2. id int,
  3. name varchar(1023),
  4. age int
  5. ) tblproperties (
  6. table_mapping = "person"
  7. );

Query data from the MySQL database

In DMS for Data Lake Analytics, run the following SQL statement to use the tbl_person table in DLA to query the data from the person table in the user-created ECS-based MySQL database.

You can also connect to the MySQL schema (hello_mysql_vpc_rds) in DLA through the MySQL client or MySQL CLI tool and read data from the MySQL database. You can also add, delete, and modify the data in the user-created ECS-based MySQL database.

  1. mysql> select * from person;
  2. +------+-------+------+
  3. | id | name | age |
  4. +------+-------+------+
  5. | 1 | james | 10 |
  6. | 2 | bond | 20 |