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
  • 相关阅读:
    CSS中position小解
    position
    mac默认安装postgresql, 如何让postgresql可以远程访问
    The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0.
    active admin gem error
    psql 无法添加超级用户
    ubuntu 15.04 安装Balsamiq Mockups 3
    Rails html 写public里图片的路径
    rails c 历史命令
    undefined local variable or method `per' for []:ActiveRecord::Relation
  • 原文地址:https://www.cnblogs.com/bsfl-study/p/9260147.html
Copyright © 2011-2022 走看看