set hive.cli.print.current.db=true/select current_database(); --hive窗口中显示当前所在的数据库
ctrl+l 或者 !clear --hive清屏
drop database 数据库名 cascade --想删库用cascade,如果数据库下有表用这个删
row format delimited fields terminated by '分隔符' --想要hive表内有数据自动分割,这句少不了
show databases like 'hive*' --hive中模糊查找(like),比如查找数据库
desc 表名 --查看表结构
desc extended/formatted 表名 --extended/formatted(工作中用这个) 可以查看详细信息,包括表的路径等
insert overwrite local directory 'liunx本地路径' row format delimited fields terminated by '分隔符' select * from 表名;
--将查询的结果以文件的形式放到本地
create table 表 as sql查询语句 --可以把查询的表数据结构直接放到新创建的表中,类似创建临时表
where 字段名 between 范围 and 范围 --这个是左右都闭合的区间
where 字段名 in ('内容') --根据内容去这个字段下查找相同的内容,也可以多个('-,'-')
select distinct 字段名 from 表名 --distinct去重