hive简单概念
hive是一种基于Hadoop的数据仓库的处理工具,目前只支持简单的类似传统关系型数据库的SQL查询,修改操作功能,他可以直接将SQL转化为MapReduce程序,开发人员不必一定要学会写MR程序,提高了开发效率。
例子:基于mysql存储的hive环境,hive元数据(hive相关表,表的各个字段属性等信息)存放在mysql数据库中,mysql数据存放在hdfs默认是/user/hive/warehouse/hive.db中
ddl 语句
mysql作为元数据存储 数据库(hive)结构目录
创建表
hive> create table test (id int, name string);
引入分区的概念,因为hive 中的select 一般会扫描整个表,这样会浪费很多时间,所以引入分区的概念
hive> create table test2 (id int, name string) partitioned by (ds string);
浏览表
hive>show tables;
引入正则表达式 类似like的功能
hive>show tables '.*t'
查看数据结构
hive> DESCRIBE test;或desc test;
修改或删除表
hive>alter table test rename to test3;
hive>alter table add columns (new_column type comment '注释')
hive>drop table test;
DM