第二部分:DML
DML包含如下操作:
•向数据表内加载文件
•LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)] |
Load 操作只是单纯的复制/移动操作,将数据文件移动到 Hive 表对应的位置。 filepath 1.相对路径,例如:project/data1 2.绝对路径,例如: /user/hive/project/data1 3.包含模式的完整 URI,例如:hdfs://namenode:9000/user/hive/project/data1 |
•将查询结果插入到Hive表中
基本模式 | INSERT OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1 FROM from_statement |
多插入模式 | FROM from_statement INSERT OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1 [INSERT OVERWRITE TABLE tablename2 [PARTITION ...] select_statement2] ... |
自动分区模式 | INSERT OVERWRITE TABLE tablename PARTITION (partcol1[=val1], partcol2[=val2] ...) select_statement FROM from_statement |
将查询结果写入HDFS文件系统
|
INSERT OVERWRITE [LOCAL] DIRECTORY directory1 SELECT ... FROM ... FROM from_statement INSERT OVERWRITE [LOCAL] DIRECTORY directory1 select_statement1 [INSERT OVERWRITE [LOCAL] DIRECTORY directory2 select_statement2] |
INSERT INTO | INSERT INTO TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1 FROM from_statement |
来源:oschina
链接:https://my.oschina.net/u/735451/blog/106418