educoder平台Hive表DDL操作(一)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

第1关:Create/Alter/Drop数据库#*********Begin*********#echoCREATEDATABASEIFNOTEXISTStest1LOCATION'/hive/test1'WITHDBPROPERTIES('creator'='John','date'='2019-02-25');ALTERDATABASEtest1SETDBPROPERTIES('creator'='Marry');DROPDATABASEtest1;#*********End*********#测评————————————————————————————————————第2关:Create/Drop/Truncate表#*********Begin*********#echoCREATEDATABASEIFNOTEXISTStest2LOCATION'/hive/test2'WITHDBPROPERTIES('creator'='John','date'='2019-02-25');CREATETABLEIFNOTEXISTStest2.student(SnoINTCOMMENT'studentsno',nameSTRINGCOMMENT'studentname',ageINTCOMMENT'studentage',sexSTRINGCOMMENT'studentsex',scoreSTRUCTChinese:FLOAT,Math:FLOAT,English:FLOATCOMMENT'studentscore')COMMENT'studentsinformationtable'TBLPROPERTIES('creator'='John','date'='2019-02-25');CREATETABLEIFNOTEXISTSstudent_infoLIKEstudent;DROPTABLEIFEXISTSstudent;#*********End*********#测评———————————————————————————————————————第3关:Alter表/列#*********Begin*********#echoCREATEDATABASEIFNOTEXISTStest3LOCATION'/hive/test3'WITHDBPROPERTIES('creator'='John','date'='2019-02-25');CREATETABLEIFNOTEXISTStest3.student(SnoINTCOMMENT'studentsno',nameSTRINGCOMMENT'studentname',ageINTCOMMENT'studentage',sexSTRINGCOMMENT'studentsex',scoreSTRUCTChinese:FLOAT,Math:FLOAT,English:FLOATCOMMENT'studentscore')COMMENT'studentsinformationtable'TBLPROPERTIES('creator'='John','date'='2019-02-25');ALTERTABLEstudentRENAMETOstudent_info;ALTERTABLEstudent_infoCHANGEagestudent_ageINTCOMMENT'studentage';ALTERTABLEstudent_infoADDCOLUMNS(birthdaySTRINGCOMMENT'studentbirthday');#*********End*********#测评———————————————————————————————————————第4关:表分区#*********Begin*********#echoCREATEDATABASEIFNOTEXISTStest4LOCATION'/hive/test4'WITHDBPROPERTIES('creator'='John','date'='2019-02-25');CREATETABLEIFNOTEXISTStest4.student(SnoINTCOMMENT'studentsno',nameSTRINGCOMMENT'studentname',ageINTCOMMENT'studentage',sexSTRINGCOMMENT'studentsex',scoreSTRUCTChinese:FLOAT,Math:FLOAT,English:FLOATCOMMENT'studentscore')COMMENT'studentsinformationtable'PARTITIONEDBY(stu_yearSTRING,subjectSTRING)ROWFORMATDELIMITEDFIELDSTERMINATEDBY'\t'COLLECTIONITEMSTERMINATEDBY','TBLPROPERTIES('creator'='John','date'='2019-02-25');ALTERTABLEstudentADDPARTITION(stu_year='2018',subject='Chinese')LOCATION'/hive/test4/student/2018/Chinese'PARTITION(stu_year='2018',subject='Math')LOCATION'/hive/test4/student/2018/Math';ALTERTABLEstudentPARTITION(stu_year='2018',subject='Math')RENAMETOPARTITION(stu_year='2018',subject='English');ALTERTABLEstudentDROPIFEXISTSPARTITION(stu_year='2018',subject='Chinese');#*********End*********#测评

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功