zoukankan      html  css  js  c++  java
  • impala基础

    impala:

    查询impala表时一定要加库名
    使用级联删除带有表的数据库:DROP database name cascade;

    insert插入的两种方式:

    1. insert into employee (ID,NAME,AGE,ADDRESS,SALARY)VALUES (1, 'Ramesh', 32, 'Ahmedabad', 20000 );
    2.不指定列值,注意顺序
    insert into employee values (2, 'Khilan', 25,'Delhi', 15000 );
    overwrite覆盖Insert overwrite employee values (1, 'Ram', 26, 'Vish', 370);

    desc customer;获取表的字段和类型

    alter

    1.重命名:ALTER TABLE oldname RENAME TO newname;
    2.向表中添加列:ALTER TABLE users ADD COLUMNS (account BIGINT, phone BIGINT);
    3.从表中删除列:ALTER TABLE users DROP account
    4.改变表中的列名以及列的类型:
    ALTER TABLE name CHANGE column_name new_name new_type
    清除表中的数据:truncate table_name;

    视图与表的区别:

    1.视图(view)是在基本表之上建立的表,它的结构(即所定义的列)和
    内容(即所有数据行)都来自基本表,它依据基本表存在而存在。
    2.一个视图可以对应一个基本表,也可以对应多个基本表,基于一个表也可以建立多个视图。
    视图是基本表的抽象和在逻辑意义上建立的新关系。
    3.表可以建立各种触发器,可以建立索引,可以建立主健、约束等。但是视图不能建立这些
    对象(视图可以建立替代触发器)。表和视图可以更新,但是视图的更新受到约束。

    排序:Select * from customers ORDER BY id asc;

    asc升序,desc降序
    分组聚合:Select name, sum(salary) from customers Group BY name;

    过滤:select max(salary) from customers group by age having max(salary) > 20000;

    限制输出结果:select * from customers order by id limit 4

    偏移量,跳过几行的意思:从头开始算select * from customers order by id limit 4 offset 0;

    union:合并查到的结果

    select * from customers order by id limit 3 union select * from employee order by id limit 3;

    给复杂的查询部分定义别名:
    with x as (select 1), y as (select 2) (select * from x union y);

    去重:select distinct columns… from table_name;

    hive与impala不同步:refresh或者invalid metaData+表名

  • 相关阅读:
    XCode颜色显示插件
    Xcode4的color theme保存路径
    Direct2D教程(四)Path Geometry
    Direct2D教程(六)图形也能做运算
    Direct2D教程(五)复合图形
    Direct2D教程(七)单色画刷
    Direct2D QuickStart
    Direct2D教程(一)Direct2D已经来了,谁是GDI的终结者?
    Direct2D入门
    Texture
  • 原文地址:https://www.cnblogs.com/feiyumo/p/7360470.html
Copyright © 2011-2022 走看看