zoukankan      html  css  js  c++  java
  • 初识Hive

    数据库的创建:IF NOT EXISTS是一个可选子句,也可以通过with dbproperties增加键值对属性信息

    hive> create database if not exists GameDW;
    OK
    Time taken: 0.013 seconds

    或者

    hive> create schema if not exists GameDW;
    OK
    Time taken: 0.007 seconds

    Create Table是用于在Hive中创建表的语句。

    语法

    CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.] table_name
    
    [(col_name data_type [COMMENT col_comment], ...)]
    [COMMENT table_comment]
    [ROW FORMAT row_format]
    [STORED AS file_format]

    创建一个以制表符为字段分割,以换行符为行分割的表,以文本存储;

    hive> create table if not exists gamerole(id int,rolename string,createtime date,zoneid int)
    > comment "roleinfo table"
    > row format delimited
    > fields terminated by ' '
    > lines terminated by ' '
    > stored as textfile ;

    修改数据库属性

    数据库的元数据信息不可更改的,只能修改属性

    hive> alter database gamedw set dbproperties("creator"="tianyongtaao")
    > ;
    OK
    Time taken: 0.075 seconds

    查看数据库属性

    hive> describe database gamedw;
    OK
    gamedw hdfs://localhost:9000/user/hive/warehouse/gamedw.db root USER
    Time taken: 0.009 seconds, Fetched: 1 row(s)

    hive> describe database extended gamedw;
    OK
    gamedw hdfs://localhost:9000/user/hive/warehouse/gamedw.db root USER {creator=tianyongtaao}
    Time taken: 0.011 seconds, Fetched: 1 row(s)

     删除数据库

    hive 不允许删除含有表的库,只有先删除表,才能删掉数据库;后面加上CASCADE(级联),就会在删除数据库前,先删除库里面的表

    ;不用CASCADE,使用restrict和默认删除一样 ,不能删除存在表的数据库;

    hive> drop database if exists aaa CASCADE;
    OK
    Time taken: 0.002 seconds

     subordinate  [səˈbɔ:rdɪnət] 下属

    deduction 扣除

  • 相关阅读:
    Python从文件中读取数据
    Python中类的继承
    Python中的类(2)
    Python中的类
    自动登陆抽屉(1)
    爬取汽车之家新闻
    Django简介
    web应用,http协议简介,web框架
    CentOS7安装python3.6
    MySQL之索引
  • 原文地址:https://www.cnblogs.com/playforever/p/8005546.html
Copyright © 2011-2022 走看看