All Products
Search
Document Center

Create a Table Store table and read data from the table

Last Updated: Jul 25, 2019

Create a Table Store table

The following example describes how to connect to DLA by using a MySQL CLI, and create a Table Store table in DLA.

  1. mysql> CREATE EXTERNAL TABLE nation (
  2. N_NATIONKEY bigint not NULL ,
  3. N_COMMENT varchar NULL ,
  4. N_NAME varchar NULL ,
  5. N_REGIONKEY varchar NULL ,
  6. PRIMARY KEY (`N_NATIONKEY`)
  7. );

The field names and sequence must be the same as those in Table Store. For more information about the field types, see Data type comparison between Table Store and DLA in Background and preparations.

After you create the table, DLA automatically synchronizes data in the Table Store table to the mapping table in DLA.

Read data from Table Store

After the data in Table Store is synchronized to DLA, you can run the standard MySQL statement to query the data.

  1. mysql> select count(*) from nation;
  2. +-------+
  3. | _col0 |
  4. +-------+
  5. | 25 |
  6. +-------+
  7. 1 row in set (1.19 sec)
  8. mysql> select * from nation;
  9. +-------------+--------------------------------------------------------------------------------------------------------------------+----------------+-------------+
  10. | n_nationkey | n_comment | n_name | n_regionkey |
  11. +-------------+--------------------------------------------------------------------------------------------------------------------+----------------+-------------+
  12. | 0 | haggle. carefully final deposits detect slyly agai | ALGERIA | 0 |
  13. | 1 | al foxes promise slyly according to the regular accounts. bold requests alon | ARGENTINA | 1 |
  14. | 2 | y alongside of the pending deposits. carefully special packages are about the ironic forges. slyly special | BRAZIL | 1 |
  15. | 3 | eas hang ironic, silent packages. slyly regular packages are furiously over the tithes. fluffily bold | CANADA | 1 |
  16. | 4 | y above the carefully unusual theodolites. final dugouts are quickly across the furiously regular d | EGYPT | 4 |
  17. | 5 | ven packages wake quickly. regu | ETHIOPIA | 0 |
  18. | 6 | refully final requests. regular, ironi | FRANCE | 3 |
  19. | 7 | l platelets. regular accounts x-ray: unusual, regular acco | GERMANY | 3 |
  20. | 8 | ss excuses cajole slyly across the packages. deposits print aroun | INDIA | 2 |
  21. | 9 | slyly express asymptotes. regular deposits haggle slyly. carefully ironic hockey players sleep blithely. carefull | INDONESIA | 2 |
  22. | 10 | efully alongside of the slyly final dependencies. | IRAN | 4 |
  23. | 11 | nic deposits boost atop the quickly final requests? quickly regula | IRAQ | 4 |
  24. | 12 | ously. final, express gifts cajole a | JAPAN | 2 |
  25. | 13 | ic deposits are blithely about the carefully regular pa | JORDAN | 4 |
  26. | 14 | pending excuses haggle furiously deposits. pending, express pinto beans wake fluffily past t | KENYA | 0 |
  27. | 15 | rns. blithely bold courts among the closely regular packages use furiously bold platelets? | MOROCCO | 0 |
  28. | 16 | s. ironic, unusual asymptotes wake blithely r | MOZAMBIQUE | 0 |
  29. | 17 | platelets. blithely pending dependencies use fluffily across the even pinto beans. carefully silent accoun | PERU | 1 |
  30. | 18 | c dependencies. furiously express notornis sleep slyly regular accounts. ideas sleep. depos | CHINA | 2 |
  31. | 19 | ular asymptotes are about the furious multipliers. express dependencies nag above the ironically ironic account | ROMANIA | 3 |
  32. | 20 | ts. silent requests haggle. closely express packages sleep across the blithely | SAUDI ARABIA | 4 |
  33. | 21 | hely enticingly express accounts. even, final | VIETNAM | 2 |
  34. | 22 | requests against the platelets use never according to the quickly regular pint | RUSSIA | 3 |
  35. | 23 | eans boost carefully special requests. accounts are. carefull | UNITED KINGDOM | 3 |
  36. | 24 | y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be | UNITED STATES | 1 |
  37. +-------------+--------------------------------------------------------------------------------------------------------------------+----------------+-------------+

According to the IDs in the following figure, you can see that the data queried in DLA is the same as that in Table Store. Then you can use DLA to analyze data.

dla

More information

Use DLA to read logs in OSS