Hive创建表的基本方式

来源:互联网 发布:vmware 8.5 mac破解版 编辑:程序博客网 时间:2024/05/19 07:10
创建表的方式
##方式一 create + load 
create [external] table table_name(
col1_name col1_type,
...
coln_name coln_type
)
row  format delimited fields terminated  by '\t';


//load加载数据
load data [local] inpth '本地文件(linux)/HDFS' [overwrite] into table  table_name;


##方式二  like + load 
##复制表结构
create table tableB like tableA;    //首先必须要有tableA


//load加载数据
laod data [local] inpth '本地文件(linux)/HDFS' [overwrite] into table  table_name;


*** ##方式三  as 创建表的同时加载数据
create table tableB row format delimited filelds termianted by ','  as select * from tableA;   //首先必须要有tableA


create table emp_as row format delimited fields terminated by ',' as select empno,empname,salary from emp_part1;


 ##方式四 create  + insert
//创建表
create table emp_insert(
id int,
name string,
job string,
salary float
)
row format  delimited fields terminated by ',';


//insert into 加载数据
insert into table emp_insert select empno,empname,empjob,salary from emp_part1 where day='20170308' and  hour='14';


overwrite/into 二者不能连着写 要么是overwrite 要么是into,推荐用overwrite
原创粉丝点击