启动Hive
[hadoop@hadoop000 ~]$ cd $HIVE_HOME
[hadoop@hadoop000 hive-1.1.0-cdh5.15.1]$ hive
创建数据库:create database test_db;(分号;别忘了加)
创建表test_db
hive> create table helloworld(id int,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t’;
查看数据库test_db都有哪些表
hive> show tables;
查询表helloworld里面的内容
hive> select * from helloword;
将/home/hadoop/data/helloworld.txt写入表helloworld
hive> load data local inpath ‘/home/hadoop/data/helloworld.txt’ overwrite into table helloworld;
统计表helloworld有多少条数据,利用MapReduce
hive> select count(1) from helloworld;
查看当前hive在哪个数据库
hive> set hive.cli.print.current.db=true;
hive (default)> show databases;(当前在default数据库)
清除当前屏幕
hive> !clear;
删除数据库:删除的数据库必须为空,如果不为空则无法删除
hive (test_db)> drop database hive3;
查看匹配某些字符的数据库有哪些
hive (hive2)> show databases like ‘hive*’;