hive从建库到建表

登陆(docker中):
beeline -u "jdbc:hive2://localhost:10000/default

建库:
select current_databases();
usedefault
create database myhive1
use myhive1

建表:(有LOCATION的是外部表)
CREATE EXTERNAL TABLE IF NOT EXISTS employee_external ( 
 name string,
 work_place ARRAY,
 sex_age STRUCT,
 skills_score MAP,
 depart_title MAP>
)
COMMENT 'This is an external table'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
COLLECTION ITEMS TERMINATED BY ','
MAP KEYS TERMINATED BY ':'
STORED AS TEXTFILE
LOCATION '/user/dayongd/employee';
(ppt P26)

查表:
select * from 

推文件(docker 中):
                          (在hdfs中建个文件夹 hdfs dfs -mkdir /cjr)

外部表:
hdfs dfs -put xxx.txt /...//  
//这里的路径(因为是外部表)就是LOCATION:内部表的话就是apps/hive//
内部表:
hdfs dfs -put xxx.txt /apps/hive/warehouse//

删除表:
drop table ;

-------------------------------------------------------------------------------------------
CREATE EXTERNAL TABLE IF NOT EXISTS customers_internal2 (
number int,
name string,
name2 string,
useless1 string,
useless2 string,
info1 string,
info2 string,
info3 string,
info4 int
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
COLLECTION ITEMS TERMINATED BY ' '
MAP KEYS TERMINATED BY ':'
STORED AS TEXTFILE;

 

你可能感兴趣的:(hive从建库到建表)