1. 先建库
- create database if not exists hive; #创建数据库
- show databases; #查看 Hive 中包含数据库
- show databases like 'h.*'; #查看 Hive 中以 h 开头数据库
2. 建表之前先输入:
use hive(库名); #切换到 hive 数据库下
3. 建表
- create table if not exists hive.stu(id int,name string)
- row format delimited fields terminated by '\t'(文档通过 table 间隔);
4. 把文件中的数据装载到表中
load data local inpath '/usr/local/hadoop/examples/stu.txt' overwrite into table lc;
5. 如果查询的值为 NULL 的话启动 MySQL;
MySQL -u root -p;
输入 alter database hive character set latin1;
6.cd .. 是返回上一层目录
来源: http://www.bubuko.com/infodetail-3286877.html