hive 基础知识1

hadoop hive (重点)day-6

他是一个储存仓库

1)hive的元数据(类似与表,列的长度等)存储在mysql上面

创建/拷贝建立新表格

1)create table table_name like old_table //只有表格

2)create table table_name as select * from old_table

添加数据四种方法:

1)insert into table_name select '数据' union all 后面跟数据

2)with t as (select 数据)insert into table_name select * from t;

3)1)创建表格时添加 :location 'hdfs路径'

​ 2)将本地文件上传到hdfs

​ 3)数据将会自动导入表格

4)load data local inpath '路径' into table 表名(如果不加local则可添加hdfs中的数据)

清空表内数据: truncate table table_name;

命令

1)查看表更详细的信息:desc formatted 表名

2)显示表格:show create 表名

3)清空表内数据: truncate table table_name;

注意点

1)外部表在创建时多加一个 external,其底部添指定地址location 'hdfs的文件地址'

2)临时表是在创建是多加一个temporary

实例一:
//使用数据库
use mydemo;(默认数据库名:default)
//新建一个表
create table userinfos(
userid int,
username structfirstname:string,lastname:string,
password string,
likes array<string>,
scores map<string,int>
)
row format delimited 
fields terminated by '|'
collection items terminated by ','
map keys terminated by ':'
stored as textfile;



 

转载于:https://www.cnblogs.com/tudousiya/p/11235242.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值