DML之加载和导出数据
程序员文章站
2024-02-21 18:58:40
...
Loading files into tables
LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)]
LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2 ...)] [INPUTFORMAT 'inputformat' SERDE 'serde'] (3.0 or later)
LOCAL:本地系统,如果没有写LOCAL那么就是指的是HDFS的路径
OVERWRITE:是否数据覆盖,如果没有OVERWRITE那么就是数据追加,有的话就是先删除然后再写入
LOAD DATA LOCAL INPATH ‘/home/hadoop/data/emp.txt’ OVERWRITE INTO TABLE emp;
LOAD DATA INPATH ‘hdfs://hadoop000:8020/data/emp.txt’ INTO TABLE emp;
把emp里面的内容写入emp1中,在工作中临时表用的很多
hive (default2)> create table emp1 as select * from emp;
Writing data into the filesystem from queries
INSERT OVERWRITE [LOCAL] DIRECTORY directory1
[ROW FORMAT row_format] [STORED AS file_format] (Note: Only available starting with Hive 0.11.0)
SELECT ... FROM ...
INSERT OVERWRITE LOCAL DIRECTORY ‘/tmp/hive/’ ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ select empno,ename,sal,deptno from emp;
ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’ 以\t为分隔符
Hive不推荐使用一以下操作,因为非常消耗性能
下一篇: C#中实现抽象类里建立静态方法