zoukankan      html  css  js  c++  java
  • hive常用命令和语句

    desc  database/schema,table_name,view_name;

    show create table xxx;

    排序:

    select * from  表名 order by  字段名;           #正序

    select * from  表名 order by  字段名 desc;    #倒序

    #命令主要是用来解决通过hdfs dfs -put或者hdfs api写入hive分区表的数据在hive中无法被查询到的问题。只需要运行MSCK REPAIR TABLE命令,hive就会去检测这个表在hdfs上的文件,把没有写入metastore的分区信息写入metastore。(即把hdfs路径里匹配的分区挂在表上)

    msck repair table

    https://blog.csdn.net/opensure/article/details/51323220

    DDL见: D:数据仓库PART26 Hive优化hive优化3

    Union all(查)

    2/ #查询司机表当前时间前6日当天分区里的这些字段

    SELECT
    a.dt,
    a.city_id,
    a.city_name,
    a.product_id,
    a.driver_id,
    a.phone_number
    FROM oride_dw.dim_oride_driver_base a    #表示司机表的别名
    where a.dt=DATE_SUB(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),6) limit 10;#表示当前时间减去6天的值

    unix_timestamp()是取系统时间函数

    要查这个函数的结果,可以在beeline命令行输入select加函数查看:

    select DATE_SUB(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),6) 

    #取前一天的
    SELECT
    a.dt,
    a.city_id,
    a.city_name,
    a.product_id,
    a.driver_id,
    a.phone_number
    FROM oride_dw.dim_oride_driver_base a
    where a.dt=DATE_SUB(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),1) limit 10;

  • 相关阅读:
    DS博客作业05--树
    DS博客作业03--栈和队列
    DS博客作业02--线性表
    DS博客作业01-日期抽象数据类型设计和实现
    easyx的基础应用教程
    C语言博客作业06--结构体&文件
    python接口自动化
    fiddler的使用
    python接口自动化——初级
    python.day.10——面向对象(二)
  • 原文地址:https://www.cnblogs.com/hongfeng2019/p/11436967.html
Copyright © 2011-2022 走看看