hive中的命令:
显示数据库:show databases;(默认只有一个default数据库)
选中数据库:use default;
显示表:show tables;
删除表:drop table;
创建库:create database test;
--------------------
创建表:第一种方式
create external table test01(id int,name string)
row format delimited fields terminated by '\t' ;
-------------如下图所示(加上参数external表示是外部表)-----------
第二种方式:create table if not exists emp_copy as select * from less01.emp;
第三种方式:create table if not exists emp_like lesson01.emp;
第一种是最常用的,第二种使用as关键字,会将表的结构和数据映射成一张新的表
第三种使用like关键字,会将表的结构进行复制,并不会将数据复制
创建分区表create table aaa()partitioned by (month string,day string)row format delimited fields terminated by '\t' ;
--------------------------------------------------------------
向表中插入数据:load data local inpath 'student.txt' into table student ;
向表中加载本地数据:load data local input "/opt/student.txt" into table student;
查询表:select * from student;(默认不走mapreduces程序)
select name from student;(走map程序)
显示函数:show functions;
查看表结构:desc formatted 表名;
清空表数据:truncate table emp_copy;
退出:quit;