0.Hive的使用
1.hive的基本使用
1.创建库:create database if not exists mydb;
2.查看库:show databases;
3.切换数据库:use mydb;
4.创建表:create table if not exists tbname(id string,name string);
create table tbname(id String,name String) row format
delimited fields terminated by ',';
5.查看表列表:show tables;
6.插入数据:insert into tbname values('1','wangsan'),('2','lisi');
7.查询数据:select * from tbname;
8.导入数据:
a)导入HDFS数据:load data inpath '/user.txt' into table tbname;
b)导入本地数据:load data local inpath '/home/hadoop/user.txt' into table tbname;
9.再次查询数据:select * from tbname;
使用hive shell时,可以使用以下命令:
set hive.exec.mode.local.auto=true;开启本地服务
set hive.cli.print.header=true;表头打印
2.DDL操作
2.1库操作
2.1.1创建表
语法结构:
create database if not exists dbname
[comment database_comment]此处添加标注
[location hdfs_path]指定hdfs的存储路径
[with dbproperties(property_name=