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;

  • 相关阅读:
    [转]AJAX POST请求中参数以form data和request payload形式在servlet中的获取方式
    C#文档注释
    VS 单元测试项目,测试的时候运行按钮不可用
    获取泛型类的Type
    Sql 复习(4)
    Sql 复习(3)
    sqlserver的soundex
    sqlserver的trim
    Sql 复习(2)
    糟糕的设计
  • 原文地址:https://www.cnblogs.com/hongfeng2019/p/11436967.html
Copyright © 2011-2022 走看看