4、使用數(shù)據(jù)庫蝠咆、查看表
hive> use a;
OK
Time taken: 0.014 seconds
hive> show tables;
OK
Time taken: 0.058 seconds
5康聂、設(shè)置數(shù)據(jù)庫名的顯示
hive> set hive.cli.print.current.db=true;
$ bin/hive --hiveconf hive.cli.print.current.db=true;
6贰健、建表
hive (a)> create table if not exists student(id int,name string) row format delimited fields terminated by '\t' stored as textfile;
OK
Time taken: 0.131 seconds
7、加載數(shù)據(jù)
cd /home/hadoop/
ls
cd datas
pwd 打印當(dāng)前目錄
rz 上傳文件
[hadoop@host-10-10-10-186 datas]$ rz
hive (a)> insert into table student(id,name) values(100,'zhang');
確定文件的位置:
/home/hadoop/datas/student.tsv
hive (a)> load data local inpath '/home/hadoop/datas/student.tsv' into table student;
hive (a)> select * from student;
8恬汁、
設(shè)置顯示表頭:
hive (a)> set hive.cli.print.header=true;
hive (a)> select * from student;
不顯示表頭:
hive (a)> set hive.cli.print.header=false;
9伶椿、
查看文件具體信息
$ cat student.tsv
刪除:
rm -rf student.tsv
操作流程:
首先建表:
hive (a)>create table if not exists student(id int,name string) row format delimited fields terminated by '\t' stored as textfile;
$ cd /home/hadoop/
$ ls
$ cd datas
$ ls
$ cat student.tsv
(在本地?cái)?shù)據(jù)上傳:$ rz :已上傳,不用操作)
$ pwd
顯示的結(jié)果:
eg:不是絕對的氓侧,看你自己的目錄就可以了
/home/hadoop/datas
hive (a)>load data local inpath '/usr/local/apache-hive-1.2.1-bin/student.tsv' into table student;
hive (a)> select * from student;
hive (a)> set hive.cli.print.header=true;
可視化工具:hue