zoukankan      html  css  js  c++  java
  • hive基础操作—(1)

     执行./hive命令后,进入CLI(shell)模式;

    1、创建数据库,语句:

    create database school;

    2、展示所有的数据库,语句:

     show databases;

    3、选择使用的数据库,语句:

    use school;

    4、创建表语句(简单),语句:

    create table student (id int, name String) row format delimited fields terminated by ' ';

    后面的语句是指定列之间的分隔符。

    5、向表中导入数据:

    首先新建一个student.txt,并插入如下内容:

    1       zhangsan
    2       lisi
    3       wangwu
    4       zhaoliu

    然后,执行:load data local inpath '/home/dyh/hive/student.txt' into table student;

    6、查询表中的数据,语句:

    select *from student;

    7、统计表student中的数量,语句:

    select count(*) from student;

    执行改语句,就可以看到hive自动生成maprduce程序,进行map和reduce操作过程。

    8、安装姓名排序,语句:

    select *from student order by name desc;

    select*from student order by name asc;

  • 相关阅读:
    hdu 2546 饭卡
    poj 2262 Goldbach's Conjecture
    poj 1287 Networking
    poj 2377 Bad Cowtractors
    poj 1789 Truck History
    poj 2349 Arctic Network
    poj 1258 Agri-Net
    acdream 20140730 D题
    hdu 1012 素数判定
    hdu 2098 分拆素数和
  • 原文地址:https://www.cnblogs.com/dyh004/p/7907929.html
Copyright © 2011-2022 走看看