ODPS SQL <for 数据操作语言DML>

基本操作:

查询:

SELECT [ALL | DISTINCT] select_expr, select_expr, ...
FROM table_reference
[WHERE where_condition]
[GROUP BY col_list]
[ORDER BY order_condition]
[DISTRIBUTE BY distribute_condition [SORT BY sort_condition] ]
[LIMIT number] 

更新:

INSERT OVERWRITE|INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)] [(col1,col2 ...)]
select_statement
FROM from_statement;

表关联:

join_table:
        table_reference join table_factor [join_condition]
        | table_reference {left outer|right outer|full outer|inner} join table_reference join_condition
    table_reference:
        table_factor
        | join_table
    table_factor:
        tbl_name [alias]
        | table_subquery alias
        | ( table_references )
    join_condition:
        on equality_expression ( and equality_expression )

演示内容:

使用DML:

*查询已有数据

*使用表连接查询数据

*覆盖更新

*追加更新

 

//上传演示数据
odps@ sdrtest>tunnel upload /root/.odpscmd/t_people.txt t_people;
//查看演示数据
odps@ sdrtest>select * from t_people;
+------------+------+
| id         | name |
+------------+------+
| 1          |  Michael Jordan |
| 2          |  Angela Dorthea Merkel |
| 3          |  Bruce Willis |
| 4          |  Kim Kardashian |
| 5          |  Jhon Knight |
| 6          |  Maria Sharapova |
| 7          |  Chiang Kai-shek |
| 8          |  Jennifer Aniston |
| 9          |  David Beckham |
| 10         |  Dragon Lady |
+------------+------+
odps@ sdrtest>select count(*),id from t_people group by id having count(*) > 0;

ID = 20190414051444876gfk3c692
Job Queueing.
----------------------------------------------------------------------------------------------
                    STAGES        STATUS  TOTAL  COMPLETED  RUNNING  PENDING  BACKUP
M1_job_0 .................    TERMINATED      1        
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值