全部产品
云市场

创建Table Store表并读取数据

更新时间:2019-06-06 10:05:37

创建Table Store表

以下示例通过MySQL命令行工具连接DLA,然后在DLA中创建Table Store表。

  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. );

字段的名称、顺序需要与Table Store中的字段名称、顺序相同。字段的数据类型请参见背景信息以及准备工作中的Table Store与DLA数据类型对比

表创建成功后,DLA自动将Table Store中的表数据同步至DLA的映射表中。

读取Table Store数据

Table Store中的数据同步至DLA中之后,您就可以使用标准SQL语法来查询数据。

  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. +-------------+--------------------------------------------------------------------------------------------------------------------+----------------+-------------+

从下图中的id可以看出,DLA中查询到的数据与Table Store中的数据完全相同,接下来您就可以使用DLA进行数据分析了。

dla

更多信息

通过DLA读取OSS上的日志文件