hive之managed table创建

摘要:
欢迎来到Live-0.1.0的世界,现在我们将使用ManagedTables:1.hive˃createdatabase fnotexisdataprocess˃comment“analyzeclusterdata”˃location“/home/landen/UntarFile/hive-0.10.0/user/hhive/warehouse”;注意

Welcome to the world of Hive-0.10.0, now we will use Managed Tables:

1. hive> create database if not exists dataprocess

           >  comment 'analyze cluster data'

           >  location '/home/landen/UntarFile/hive-0.10.0/user/hive/warehouse';

Notice: you can optionally specify a location for the table data(as opposed to metadata, which the metastore will always hold). By default, hive always creates the table's directory under the directory for the enclosing database. The exception is the default database. It doesn't have a directory under /user/hive/warehouse(unless explicitly overridden).

2. hive> describe database financials;

    financials   analyze cluster data 

    hdfs://localhost:9000/home/landen/UntarFile/hive-0.10.0/user/hive/warehouse/dataprocess.db

3. hive> use dataprocess;

    and you can set a property to print the current database as part of the prompt

    hive> set hive.cli.print.current.db=true;

   hive(dataprocess)> ......

4. hive> drop database if exists dataprocess;

    Notice: By default, Hive won't permit you to drop a database if it contains tables. You can either drop the tables first or append the 'CASCADE' keyword to the command.

    hive> drop database if exists dataprocess CASCADE;

Using the 'RESTRICT' keyword instead of CASCADE is equivalent to the default behavior, where a database is dropped, it's directory is also deleted.

5. hive> alter database dataprocess

           > set dbproperties('edited-by' = 'kevin');

Now let's create a emplyees in the database of human_resources:

6. hive> use human_resources;

    hive> set hive.cli.print.current.db=true;

    hive(human_resources)> create table if not exists employees(

                                           > name string comment 'employee name',

                                           > number string comment 'employee work number')

                                           > comment 'describe the employee table'

                                           > tblproperies('creator'='landen', 'created_at'='2013-03-25 20:02');

    hive(human_resources)>  show tblproperties employees;

Notice: you can also copy the schema(but the data) of an existing table:

7. hive> create table if not exists mydb.employees

           >  like employees;

8. hive> use default;

    hive> show tables in mydb;

employees

9. hive> use mydb;

    hive> show tables 'empl.*';

Notice: if you only want to see the schema for a particular column, append the column to the table name,such as

10.  hive> describe mydb.employees.name

name string Employee name

      Now the tables we have created so far are called managed tables or sometimes called internal tables, because Hive controls the lifecycle of their data(more or less). As we've seen, Hive stores the data for these tables in a subdirectory under the directory defined by hive.metastore.warehouse.dir by default.

      However, managed tables are less convinent for sharing with other tools. For example, suppose we have data that is created and used primarily by Pig or other tools, but we want to run some quries against it, but not give Hive ownership of the data. So we can define an external table that points to that data, but doesn't take ownership of it.

  

免责声明:文章转载自《hive之managed table创建》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇xml schema中的命名空间关于js判断鼠标移入元素的方向——上下左右下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

将txt、csv等文本文件导入Hive

将txt、csv等文本文件导入Hive 目录 将txt、csv等文本文件导入Hive 00.数据在虚拟机外 01.启动hadoop、hdfs 02.将文件放置在hdfs目录下 03.登录hive并进入指定数据库 04.根据文件创建表 05.执行导入语句 00.数据在虚拟机外 如果数据在虚拟机内,请跳过此步,直接执行接下来的操作。 推荐使用Sec...

IOS 使用Autolayout实现UITableView的Cell动态布局和高度动态改变

如何在UITableViewCell中使用Autolayout来实现Cell的内容和子视图自动计算行高,并且能够保持平滑滚动的? 这个问题得到了300+的支持和450+的收藏,答案得到了730+的支持,很详细的说明了如何在iOS7和iOS8上实现UITableView的动态行高功能,并且这个答案对实现UICollectionView的动态行高也具有参考...

scope.row中属性值展示

<el-table-column align="center" label="Id" width="95"> <template slot-scope="scope"> {{ scope.$index }} </template> </el-...

Hadoop学习笔记—16.Pig框架学习

Hadoop学习笔记—16.Pig框架学习 一、关于Pig:别以为猪不能干活 1.1 Pig的简介 Pig是一个基于Hadoop的大规模数据分析平台,它提供的SQL-LIKE语言叫Pig Latin,该语言的编译器会把类SQL的数据分析请求转换为一系列经过优化处理的MapReduce运算。Pig为复杂的海量数据并行计算提供了一个简单的操作和编程接口。 C...

linux路由表配置

一、原理说明 1、路由表(table)从0到255进行编号,每个编号可以对应一个别名,编号和别名的对应关系在linux下放在/etc/iproute2/rt_tables这个文件里,一般0编号的table对应的别名为upspec,255编号对应的别名为local,254和253对应的别名分别为main和default,我们通常用route命令配置和查看的...

MySQL数据库增删改字段(属性)

MySQL数据库的各种操作今天在这里总结一下: 一、增加 1.在已有的表中添加新的字段: 首先是增加表的字段,比如一张表原本没有字段“ Time ”,现在我们要增加这样一个字段,可以用下面的SQL语句实现: alter table +table的名字+ add + 字段名字 + 数据类型+分号,以下SQL在表testTable中插入了2个字段,font和a...