zoukankan      html  css  js  c++  java
  • hive学习(一)

    hive基本操作命令:

    1.虚拟机上hive进入控制台(mysql):
        查看数据库:show databases;
        创建数据库:create database student; 
            此数据库建立在hdfs上面,可以通过windows下面的mysql数据库里面的hive数据库里面的dbs表查看创建的数据库。
            select * from dbs;
            也可以在虚拟机下查看:
            show databases;
        创建表:create table if not exists myhive.employee ( eid int, name String,salary String, destination String) comment 'Employee details'(描述解释)
    row format delimited fields terminated by ' '( 分隔) lines terminated by ' ' stored as textfile(行用 分隔,存储为textfile文本格式); 此表建立在hdfs上面,可以通过windows下面的mysql数据库里面的hive数据库里面的dbs表查看创建的数据库。 select * from tbls; 也可以在虚拟机下查看: show tables; 查看表所在的位置: show create table tbls; LOCATION:显示的就是表在hdfs的位置 查看表信息: desc 表名; desc formatted 表名; --> 所有表的信息 查询信息: select eid,name from employee limit 2,4; --> 查询第二行到第四行的数据 select eid,name from employee where eid is not null; 查看hdfs上面的文件: dfs -ls -R; Lunix命令执行: !命令 --> 例:!cat derby.log(查看log日志) 清屏: ctrl + l / !clear 退出hive: exit
    2.给数据库导入信息
        load data local(不写表示hdfs上面) inpath '/home/yhj/Desktop/employee.txt' overwrite(覆盖重写,不写则在后面继续追加) into table myhive.employee(表)
    3.hive命令
        定义变量:
            hive --define foo=bar
        查看变量:
            hive
            set foo; --> foo=bar
        修改变量foo:
            set foo=bar1;
            set foo; --> foo=bar1
    
            set hivevar:foo --> hivevar:foo=bar
            set define:foo --> define:foo=bar
    
            set hivevar:foo=bar1
            set define:foo=bar2
  • 相关阅读:
    node.js入门
    分布式爬虫
    ES6入门
    Vue.js入门
    用scrapy爬取亚马逊网站项目
    垃圾回收器
    HTTP协议详解
    有效的邮箱地址
    C#中正则表达式的使用
    抽象类
  • 原文地址:https://www.cnblogs.com/bsfl-study/p/9260147.html
Copyright © 2011-2022 走看看