hive常用命令

上传人:小** 文档编号:93319629 上传时间:2019-07-19 格式:DOC 页数:4 大小:13.53KB
返回 下载 相关 举报
hive常用命令_第1页
第1页 / 共4页
hive常用命令_第2页
第2页 / 共4页
hive常用命令_第3页
第3页 / 共4页
hive常用命令_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《hive常用命令》由会员分享,可在线阅读,更多相关《hive常用命令(4页珍藏版)》请在金锄头文库上搜索。

1、Hive常用命令:1、 查看数据库 show databases; /查看已经存在的数据库 describe database test; /查看某个已经存在的数据库2、创建数据库 create database test; create database if not exists test; create database test2 location /user/hadoop/temp; /制定数据库创建的目录3、 删除数据库 drop database if exists test1 cascade;4、切换当前工作的数据库 use test2;5、 查看数据库中的表 show tab

2、les; /查看当前工作的数据库中的表 show tables in test3; /查看数据库test3中的表6、 创建表 create table if not exists test.student( name string comment student name, age int comment student age, course array, body map, address struct ) comment the info of student /表的备注 row format delimited fields terminated by 001 /指定列分隔符001 c

3、ollection items terminated by 002 /指定集合元素间的分隔符002 map keys terminated by 003 /指定类型为MAP字段的键值对分割符 lines terminated by n /指定行分割符 stored as textfile /存储的文件格式 location /user/hive/warehouse/test.db/student; create table if not exists student2 like student; /复制已存在的表结构创建表(不复制数据) Hive中建表默认为管理表(managed table)

4、,当表需要被其它工具分析时,需要建立外部表(exter nal table) create exter nal table - /建立外部表 建立分区表 create table student_info( id string, name string, age int) partitioned by (province string,city string); 7、 查看表结构信息以及列的注释 desc student;8、查看表的详细信息 desc formatted student;9、 查看分区表的详细信息 describe extended student_info;10、 删除表

5、drop table student; drop table if exists student;11、 表重命名alter table student rename to student_1;12、 增加、修改、删除分区 alter table student_info add partition (province=fujain,city=fuzhou) location /user/hive/warehouse/test/fujian/fuzhou; /表必须为分区表,且province、city为分区字段 alter table student_info drop partition(province=fujian,city=fuzhou);13、 修改列信息 alter table student_1 change column age sage int comment the student ageafter name;14、 增加列 alter table student_1 add columns (new_col int);

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号