Hive的基本操作
Hive的基本操作
参考: Hive(二)hive的基本操作 - 凌-风 - 博客园
Hive - 标签 - 凌-风 - 博客园
1:创建数据库
create database userTest comment '' with dbpropertie。。。。。
2:切换数据库
use userTest;
3:删除数据库
drop database userTest;
删除数据库时要保证数据库为空,否则会报错
4:查看数据库信息
describe database extended userTest
5:创建表(内部表)
1: create table dataFlow(phoneNumber string,upFlow int,downFlow int);
2:创建以某个分隔符的表
create table dataFlow(phoneNumber string,upFlow int,downFlow int) row format delimited fields terminated by ',' ;
3:
create table [external] employees(
name string,
salary float,
subordinates array<string>,
deductions map<string,float>,
address struct<street:string,city:string,state:string,zip:int>
)
row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile;
6:查看数据表的创建过程
show create table dataFlow;
7:查看数据表信息
desc dataFlow;
desc [extended,formatted] tablename;
8:删除数据表
drop table 数据库名.表名
9:数据导入
内部: load data local inpath '/home/bigdata/dataFlow.log' into table sand.dataFlow;
外部:load data inpath '/dataFlow.log' overwrite into table dataFlow;
10:创建表(外部表)
a、创建内部表
create table mytable (id int, name string) row format delimited fields terminated by ','
stored as textfile;
b、创建外部表
create external table mytable2 (id int, name string) row format delimited fields
terminated by ',' location '/user/hive/warehouse/mytable2';