日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

ODPS SQL for 数据操作语言DML

發(fā)布時(shí)間:2023/12/20 数据库 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ODPS SQL for 数据操作语言DML 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

基本操作:

查詢:

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;

表關(guān)聯(lián):

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

演示內(nèi)容:

使用DML:

*查詢已有數(shù)據(jù)

*使用表連接查詢數(shù)據(jù)

*覆蓋更新

*追加更新

?

//上傳演示數(shù)據(jù) odps@ sdrtest>tunnel upload /root/.odpscmd/t_people.txt t_people; //查看演示數(shù)據(jù) 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 1 0 0 0 ----------------------------------------------------------------------------------------------STAGES STATUS TOTAL COMPLETED RUNNING PENDING BACKUP---------- M1_job_0 ................. TERMINATED 1 1 0 0 0---------------------------------------------------------------------------------- R2_1_job_0 ............... TERMINATED 1 1 0 0 0 ---------------------------------------------------------------------------------------------- STAGES: 02/02 [==========================>>] 100% ELAPSED TIME: 8.17 s ---------------------------------------------------------------------------------------------- Summary: resource cost: cpu 0.00 Core * Min, memory 0.00 GB * Min inputs:sdrtest.t_people: 10 (776 bytes) outputs: Job run time: 5.000 Job run mode: fuxi job Job run engine: execution engine M1:instance count: 1run time: 3.000instance time:min: 0.000, max: 0.000, avg: 0.000input records:TableScan1: 10 (min: 10, max: 10, avg: 10)output records:StreamLineWrite1: 10 (min: 10, max: 10, avg: 10)writer dumps:StreamLineWrite1: (min: 0, max: 0, avg: 0) R2_1:instance count: 1run time: 5.000instance time:min: 0.000, max: 0.000, avg: 0.000input records:StreamLineRead1: 10 (min: 10, max: 10, avg: 10)output records:AdhocSink1: 10 (min: 10, max: 10, avg: 10)reader dumps:StreamLineRead1: (min: 0, max: 0, avg: 0)+------------+------------+ | _c0 | id | +------------+------------+ | 1 | 1 | | 1 | 2 | | 1 | 3 | | 1 | 4 | | 1 | 5 | | 1 | 6 | | 1 | 7 | | 1 | 8 | | 1 | 9 | | 1 | 10 | +------------+------------+ //使用表連接查詢數(shù)據(jù) odps@ sdrtest>select t1.* from t_people t1 join t_people t2 on t1.id=t2.id; ID = 20190414052009767gcpxmnimJob Queueing. ----------------------------------------------------------------------------------------------STAGES STATUS TOTAL COMPLETED RUNNING PENDING BACKUP M1_job_0 ................. TERMINATED 1 1 0 0 0 ----------------------------------------------------------------------------------------------STAGES STATUS TOTAL COMPLETED RUNNING PENDING BACKUP---------- M1_job_0 ................. TERMINATED 1 1 0 0 0---------------------------------------------------------------------------------- J2_1_job_0 ............... TERMINATED 1 1 0 0 0 ---------------------------------------------------------------------------------------------- STAGES: 02/02 [==========================>>] 100% ELAPSED TIME: 8.56 s ---------------------------------------------------------------------------------------------- Summary: resource cost: cpu 0.00 Core * Min, memory 0.00 GB * Min inputs:sdrtest.t_people: 10 (776 bytes) outputs: Job run time: 6.000 Job run mode: fuxi job Job run engine: execution engine M1:instance count: 1run time: 3.000instance time:min: 0.000, max: 0.000, avg: 0.000input records:TableScan1: 10 (min: 10, max: 10, avg: 10)output records:StreamLineWrite1: 10 (min: 10, max: 10, avg: 10)StreamLineWrite2: 10 (min: 10, max: 10, avg: 10)writer dumps:StreamLineWrite1: (min: 0, max: 0, avg: 0)StreamLineWrite2: (min: 0, max: 0, avg: 0) J2_1:instance count: 1run time: 6.000instance time:min: 0.000, max: 0.000, avg: 0.000input records:StreamLineRead1: 10 (min: 10, max: 10, avg: 10)StreamLineRead2: 10 (min: 10, max: 10, avg: 10)output records:AdhocSink1: 10 (min: 10, max: 10, avg: 10)reader dumps:StreamLineRead1: (min: 0, max: 0, avg: 0)StreamLineRead2: (min: 0, max: 0, avg: 0)+------------+------+ | 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 | +------------+------+ //創(chuàng)建新表用于演示追加更新: odps@ sdrtest>create table t_people_new like t_people; odps@ sdrtest>read t_people_new; +------------+------------+ | id | name | +------------+------------+ +------------+------------+ odps@ sdrtest>insert into table t_people_new select * from t_people; //查看新建的表內(nèi)寫入的數(shù)據(jù): odps@ sdrtest>read t_people_new>; +------------+------------+ | 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 | +------------+------------+ //演示追加更新 <into> odps@ sdrtest>insert into table t_people_new select * from t_people; Job Queueing. ----------------------------------------------------------------------------------------------STAGES STATUS TOTAL COMPLETED RUNNING PENDING BACKUP M1_job_0 ................. TERMINATED 1 1 0 0 0 ---------------------------------------------------------------------------------------------- STAGES: 01/01 [==========================>>] 100% ELAPSED TIME: 5.26 s ---------------------------------------------------------------------------------------------- Summary: resource cost: cpu 0.00 Core * Min, memory 0.00 GB * Min inputs:sdrtest.t_people: 10 (776 bytes) outputs:sdrtest.t_people_new: 10 (776 bytes) Job run time: 3.000 Job run mode: fuxi job Job run engine: execution engine M1:instance count: 1run time: 3.000instance time:min: 0.000, max: 0.000, avg: 0.000input records:TableScan1: 10 (min: 10, max: 10, avg: 10)output records:TableSink1: 10 (min: 10, max: 10, avg: 10)OK odps@ sdrtest>read t_people_new; +------------+------------+ | 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 | | 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 | +------------+------------+//演示覆蓋更新 <overwrite> odps@ sdrtest>insert overwrite table t_people_new select * from t_people;----------------------------------------------------------------------------------------------STAGES STATUS TOTAL COMPLETED RUNNING PENDING BACKUP M1_job_0 ................. TERMINATED 1 1 0 0 0 ---------------------------------------------------------------------------------------------- STAGES: 01/01 [==========================>>] 100% ELAPSED TIME: 5.24 s ---------------------------------------------------------------------------------------------- Summary: resource cost: cpu 0.00 Core * Min, memory 0.00 GB * Min inputs:sdrtest.t_people: 10 (776 bytes) outputs:sdrtest.t_people_new: 10 (776 bytes) Job run time: 3.000 Job run mode: fuxi job Job run engine: execution engine M1:instance count: 1run time: 3.000instance time:min: 0.000, max: 0.000, avg: 0.000input records:TableScan1: 10 (min: 10, max: 10, avg: 10)output records:TableSink1: 10 (min: 10, max: 10, avg: 10)OK odps@ sdrtest>read t_people_new; +------------+------------+ | 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>

  

others....

轉(zhuǎn)載于:https://www.cnblogs.com/sdrbg/p/10702290.html

總結(jié)

以上是生活随笔為你收集整理的ODPS SQL for 数据操作语言DML的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。