HIVE 第二章 目录和表

1.目录篇

创建表目录

create database companys

create database companys location  table

create database companys location table with dbproperties('name'='kedde','data'='2012-01-02')

查看database信息,无法查看当前表目录

describe database companys

describe database extended companys

改变默认的表目录

use companys

删除表目录

drop database financials

修改表目录属性,无法删除表属性

alter database financials setdbproperties('owner'='dirk')

 

2.表篇

新建表 mydb必须是存在的,location可以不存在,hive会新建

CREATE TABLE IF NOT EXISTS mydb.employees (

name STRING COMMENT 'Employee name',

salary FLOAT COMMENT 'Employee salary',

subordinates ARRAY<STRING> COMMENT 'Names of subordinates',

deductions MAP<STRING, FLOAT>

COMMENT 'Keys are deductions names, values are percentages',

address STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>

COMMENT 'Home address')

COMMENT 'Description of the table'

TBLPROPERTIES ('creator'='me', 'created_at'='2012-01-02 10:00:00', ...)

LOCATION '/user/hive/warehouse/mydb.db/employees';

新建表,copy已有表结构schema,不包含数据

create table if not exists mydb.empoyees link mydb.employees;

查看表

show tables;

show tables in companys;

show tables 'emp.*'; #注意是.*

查看表信息

describe extended companys.tables;

规定分隔符为/t

row format delimited fields terminated by '/t';

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值