欢迎来到天天文库
浏览记录
ID:41402391
大小:73.00 KB
页数:4页
时间:2019-08-24
《Hive常用命令》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Hive常用命令:1、查看数据库showdatabases;//查看已经存在的数据库describedatabasetest;//查看某个已经存在的数据库2、创建数据库createdatabasetest;createdatabaseifnotexiststest;createdatabasetest2location'/user/hadoop/temp';//制定数据库创建的目录3、删除数据库dropdatabaseifexiststest1cascade;4、切换当前工作的数据库usetest2;5、查看数据库中的表s
2、howtables;//查看当前工作的数据库中的表showtablesintest3;//查看数据库test3中的表6、创建表createtableifnotexiststest.student(namestringcomment'studentname',ageintcomment'studentage',coursearray,bodymap,addressstruct)comment'thein
3、foofstudent'//表的备注rowformatdelimitedfieldsterminatedby' 01'//指定列分隔符’ 01’collectionitemsterminatedby' 02'//指定集合元素间的分隔符’ 02’mapkeysterminatedby' 03'//指定类型为MAP字段的键值对分割符linesterminatedby''//指定行分割符storedastextfile//存储的文件格式location'/user/hive/warehouse/test.db/st
4、udent';createtableifnotexistsstudent2likestudent;//复制已存在的表结构创建表(不复制数据)Hive中建表默认为管理表(managedtable),当表需要被其它工具分析时,需要建立外部表(externaltable)createexternaltable--//建立外部表建立分区表createtablestudent_info(idstring,namestring,ageint)partitionedby(provincestring,citystring);5、查看表结
5、构信息以及列的注释descstudent;8、查看表的详细信息descformattedstudent;9、查看分区表的详细信息describeextendedstudent_info;10、删除表droptablestudent;droptableifexistsstudent;11、表重命名altertablestudentrenametostudent_1;12、增加、修改、删除分区altertablestudent_infoaddpartition(province='fujain',city='fuzhou')l
6、ocation'/user/hive/warehouse/test/fujian/fuzhou';//表必须为分区表,且province、city为分区字段altertablestudent_infodroppartition(province='fujian',city='fuzhou');13、修改列信息altertablestudent_1changecolumnagesageintcomment'thestudentage'aftername;9、增加列altertablestudent_1addcolumns(n
7、ew_colint);
此文档下载收益归作者所有