第一关:将文件中的数据导入(Load)到 Hive 表中
/********* Begin *********/
/*创建数据库*/
CREATE DATABASE IF NOT EXISTS test1
LOCATION '/hive/test1'; /*指定数据库位置*/
USE test1;
/*建表*/
CREATE TABLE IF NOT EXISTS test1.student(
Sno INT COMMENT 'student sno',
name STRING COMMENT 'student name' ,
age INT COMMENT 'student age',
sex STRING COMMENT 'student sex',
score STRUCT <chinese:FLOAT,math:FLOAT,english:FLOAT> COMMENT 'student score')
COMMENT 'students information tabe'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
COLLECTION ITEMS TERMINATED BY '-';
/*插入数据*/
load data local inpath '/home/student.txt' overwrite into table student;
/********* End *********/
select * from student;
第二关:Select 操作
--Begin
USE test2;
select * from student;
select * from student where age > 17 and sex = "female";
select * from s