专业的编程技术博客社区

网站首页 > 博客文章 正文

hive 之前操作脚本汇总(hive shell脚本)

baijin 2024-10-07 06:07:04 博客文章 3 ℃ 0 评论
create database myhive;
show databases ;
use myhive;
create table test_create_table(id int,name string);
desc test_create_table;
show create table test_create_table;
insert into test_create_table values (1,'test');
select * from test_create_table;
create external table test_extern(id int ,name string);
create external table test_extern_1(id int ,name string) location '/datas/test_extern_1';
insert into test_extern_1 values (1,'test');
select * from test_extern_1;
create table test_like like test_create_table;
desc test_like;
select * from test_like;
create table test_com(id int comment '学生ID',name string comment '学生姓名') comment '学生表';
show create table test_com;
--5
create table sales_info(sku_id string comment '商品id',sku_name string comment '商品名称',id_array array<string> comment '商品相关id列表') row format delimited fields terminated by '|' collection items terminated by ',';

load data   inpath '/datas/detail.txt' overwrite into table sales_info;
select * from sales_info;
--6
create table test_partition1(
                                sku_id string comment '商品id',
                                sku_name string comment '商品名称'
) partitioned by (sku_class string);
alter table test_partition1 add partition (sku_class='xiaomi');
show partitions test_partition1;
insert into table test_partition1 partition (sku_class='xiaomi') values ('001','xiaomi');
insert into table test_partition1 partition (sku_class='xiaomi') select sku_id,sku_name from sales_info;
select * from test_partition1;
set hive.mapred.mode=nonstrict;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table test_partition1 partition (sku_class)values ('001','xiaomi2','xiaomi');
--9
--导出到hdfs
insert overwrite directory '/datas/' select  * from sales_info;
--导出到 本地
insert overwrite local directory '/datas/sales_info' select  * from sales_info;

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表