一、数据导入
1.从本地磁盘或hdfs导入数据
load data [local] inpath "路径" [overwrite] into table table_name
partition (分区名=分区值);
//参数解读:local和overwrite是可选项,local表示从本地导入,不写local表示在hdfs导入
//overwrite是覆盖写,不写overwrite则为追加导入。
例子
load data local inpath "/opt/module/data/student.txt" overwrite into table student;
//或者现在hdfs上上传一份数据比如上传在hdfs://hadoop102:8020/test.xxx
load data inpath "/test.xxx" overwrite into table student;
2.insert导入
insert into table student2 select id,name from student where id=1001;
3.建表时as导入
create table table_name as select column_name1,column_name2 from table_name2;
4.建表时通过location加载
create table table_name
(column1 datatype,column2 datatype)
location &