1.创建库:create database if not exists mydb;
2.查看库:show databases;
3.切换数据库:use mydb;
4.创建表:create table if not exists t_user(id string, name string) 或 create table t_user(id string, name string) row format delimited fields terminated by ',';
5.查看表列表:show tables;
6.插入数据:insert into table t_user values ('1','huangbo'), ('2','xuzheng'),('3','wangbaoqiang');
7.查询数据:select * from t_user;
8.导入数据: a) 导入 HDFS 数据:load data inpath '/user.txt' into table t_user; b) 导入本地数据:load data local inpath '/home/hadoop/user.txt' into table t_user;
小技能补充:1.进入到用户的主目录,使用命令 cat /home/hadoop/.hivehistory 可以查看到 hive 执行的历史命令2.执行查询时若想显示表头信息时,
请执行命令: Hive> set hive.cli.print.header=true;
3.hive的执行日志的存储目录在${java.io.tmpdir}/${user.name}/hive.log中,假如使用hadoop用户操作的 hive,
那么日志文件的存储路径为:/temp/hadoop/hive.log
作者:爱Rap篮球写代码的蔡徐
链接:https://juejin.cn/post/6844904005756272654
来源:稀土掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。