9.3、 创建数据库表

创建student表

CREATE TABLE IF NOT EXISTS mydb1.student (name STRING, age INT, contact INT );

创建employ表

create table employee (Id INT, name STRING, age INT,address STRING, salary BIGINT);

9.3.1、 数据库表中插入数据

insert into employee (ID,NAME,AGE,ADDRESS,SALARY)VALUES (1, 'Ramesh', 32, 'Ahmedabad', 20000 );

insert into employee values (2, 'Khilan', 25, 'Delhi', 15000 );

Insert into employee values (3, 'kaushik', 23, 'Kota', 30000 );
Insert into employee values (4, 'Chaitali', 25, 'Mumbai', 35000 );
Insert into employee values (5, 'Hardik', 27, 'Bhopal', 40000 );
Insert into employee values (6, 'Komal', 22, 'MP', 32000 );

数据的覆盖

Insert overwrite employee values (1, 'Ram', 26, 'Vishakhapatnam', 37000 );
执行覆盖之后,表中只剩下了这一条数据了

另外一种建表语句

create table customer as select * from employee;

9.3.2、 数据的查询

select * from employee;

select name,age from employee;

9.3.3、 删除表

DROP table  mydb1.employee;

9.3.4、 清空表数据

truncate  employee;

9.3.5、 创建视图

CREATE VIEW IF NOT EXISTS employee_view AS select name, age from employee;

9.3.6、 查看视图数据

select * from employee_view;

9.4、 order  by语句

基础语法

select * from table_name ORDER BY col_name [ASC|DESC] [NULLS FIRST|NULLS LAST]
Select * from employee ORDER BY id asc;

9.5、group  by  语句

Select name, sum(salary) from employee Group BY name;

9.6、 having 语句

基础语法

select * from table_name ORDER BY col_name [ASC|DESC] [NULLS FIRST|NULLS LAST]

按年龄对表进行分组,并选择每个组的最大工资,并显示大于20000的工资

select max(salary) from employee group by age having max(salary) > 20000;

9.7、 limit语句

select * from employee order by id limit 4;

10、impala当中的数据表导入几种方式

第一种方式,通过load  hdfs的数据到impala当中去

create table user(id int ,name string,age int ) row format delimited fields terminated by "\t";

准备数据user.txt并上传到hdfs的 /user/impala路径下去

1       hello   15

2       zhangsan        20

3       lisi    30

4       wangwu  50

加载数据的4种方法:

第一种方式:

load data inpath '/user/impala/' into table user;

注意:没法使用load data local的方式,加载本地目录中的数据!

查询加载的数据

select  *  from  user;

如果查询不不到数据,那么需要刷新一遍数据表

refresh  user;

第二种方式:

create  table  user2   as   select * from  user;

第三种方式:

insert  into

第四种:

insert  into  select

最新文章

  1. 第四章 springboot + swagger
  2. 与JSP的初次邂逅……
  3. 如何查看PowerShell版本
  4. Android常用知识笔记
  5. web一次请求的流程
  6. TMS320VC5509A DSP学习路线(持续更新)
  7. 数据结构 : Hash Table
  8. 数据结构(主席树):HDU 5654 xiaoxin and his watermelon candy
  9. QT-利用C++仿制windown自带的记事本程序V1.0
  10. cocos2d-x spine 加载粒子特效
  11. BZOJ 3295: [Cqoi2011]动态逆序对 [CDQ分治]
  12. vue的基础知识
  13. 如何设置IntelliJ IDEA智能感知支持Jsp内置对象
  14. mysql索引小结——高性能mysql
  15. js-for (var in )遍历顺序乱了
  16. 数据存储之第三方FMDB
  17. 单点登录(SSO)
  18. 【WPF】动态设置Binding的ConverterParameter转换器参数
  19. Android开发之经常使用的时间格式
  20. Linux内存管理-高端内存(一)

热门文章

  1. wc、grep 、 cut、paste 和 tr 命令的用法
  2. Asteroids!_poj2225
  3. 多项式输出 (0)<P2009_1>
  4. nginx的preaccess 阶段的limit_req模块与limit_conn模块
  5. GO闭包
  6. spring cloud spring boot JPA 克隆对象修改属性后 无法正常的执行save方法进行保存或者更新
  7. js 原生url编码
  8. idea中scala语言自动补全变量的同时,也自动补全类型
  9. Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)E(多重集维护)
  10. android悬浮按钮(Floating action button)的两种实现方法