CREATETABLE`emp_rc`(`id` string,`name` string,`job` string,`mgr` string,`hiredate`date,`sal`double,`comm`double,`deptid` string)ROW FORMAT DELIMITED FIELDSTERMINATEDBY','
STORED AS rcfile;//指定存储文件格式
注意:rcfile存储格式的表,不能直接加载数据。只能通过其他表加载数据。
4.建表4:从其他表中加载数据
create table emp_r as 查询语句
create table emp_r as select job,avg(sal) as s from emp_rc group by job order by s desc;
insert into table emp_i 查询语句(前提这emp_i这个表是建过了)
insert into table emp_i select job,avg(sal) as s from emp2 group by job order by s desc;
复制表结构,但是不加载数据:like
create table emp_l like emp2;
执行set hive.enforce.bucketing = true;启动
insert into emp_b_p partition(dt="2020-10-16") select * from emp_0;
8.hive加载数据:
load data [local] inpath '对应的绝对路径' into table 表名 [partition(分区名称)]
例子:将本地文件加载到hive中
load data local inpath '/usr/local/soft/data/empldata.csv' into table eme_p partition(dt="2020-10-16");
例子:将hdfs路径下的数据加载到hive中
load data '/hivedata/emp_0/empldata.csv' into table emp_p partition(dt="2020-10-16");
注意:从hdfs中加载数据的时候,是将数据移动到hive对应的表目录。是移动不是复制。