启动大数据平台的Hive数据仓库,启动Hvie客户端,通过Hive查看hadoop所有文件路径(相关数据库命令语言请全部使用小写格式),将查询结果以文本形式提交到答题框中。
[root@master ~]# hive
WARNING: Use "yarn jar" to launch YARNapplications.
Logging initialized using configuration infile:/etc/hive/2.4.3.0-227/0/hive-log4j.properties
hive> dfs -ls;
Found 5 items
drwx------ -root hdfs 0 2017-04-20 18:56.Trash
drwxr-xr-x - roothdfs 0 2017-05-07 05:59.hiveJars
drwx------ -root hdfs 0 2017-05-07 05:43.staging
drwxr-xr-x -root hdfs 0 2017-05-07 05:43hbase-staging
drwxr-xr-x -root hdfs 0 2017-04-20 18:56samll-file
27.使用 Hive工具来创建数据表xd_phy_course,将phy_course_xd.txt导入到该表中,其中xd_phy_course表的数据结构如下表所示。导入完成后,通过hive查询数据表xd_phy_course中数据在HDFS所处的文件位置列表信息,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。
新:
hive> create table xd_phy_course (stnamestring,stID int,class string,opt_cour string) row format delimited fieldsterminated by '\t' lines terminated by '\n' stored as textfile;
OK
Time taken: 4.067 seconds
hive> load data local inpath'/root/phy_course_xd.txt' into table xd_phy_course;
Loading data to table default.xd_phy_course
Table default.xd_phy_course stats: [numFiles=1,totalSize=89444]
OK
Time taken: 1.422 seconds
hive> dfs -ls /apps/hive/warehouse;
Found 1 items
drwxrwxrwx -hive hdfs 0 2017-05-19 03:30/apps/hive/warehouse/xd_phy_course
28.使用Hive工具来创建数据表xd_phy_course,并定义该表为外部表,外部存储位置为/1daoyun/data/hive,将phy_course_xd.txt导入到该表中,其中xd_phy_course表的数据结构如下表所示。导入完成后,在hive中查询数据表xd_phy_course的数据结构信息,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。
hive> create external table xd_phy_course (stnamestring,stID int,class string,opt_cour string) row format delimited fieldsterminated by '\t' lines terminated by '\n' location '/1daoyun/data/hive';
OK
Time taken: 1.197 seconds
hive> load data local inpath '/root/phy_course_xd.txt'into table xd_phy_course;
Loading data to table default.xd_phy_course
Table default.xd_phy_course stats: [numFiles=1,totalSize=89444]
OK
Time taken: 0.96 seconds
hive> desc xd_phy_course2;
OK
stname string
stid int
class string
opt_cour string
Time taken: 0.588 seconds, Fetched: 4 row(s)
29.使用Hive工具来查找出phy_course_xd.txt文件中某高校Software_1403班级报名选修volleyball的成员所有信息,其中phy_course_xd.txt文件数据结构如下表所示,选修科目字段为opt_cour,班级字段为class,将以上操作命令(相关数据库命令语言请全部使用小写格式)和输出结果以文本形式提交到答题框。
新:
hive> create table xd_phy_course (stnamestring,stID int,class string,opt_cour string) row format delimited fieldsterminated by '\t' lines terminated by '\n';
OK
Time taken: 4.067 seconds
hive> load data local inpath'/root/phy_course_xd.txt' into table xd_phy_course;
Loading data to table default.xd_phy_course
Table default.xd_phy_course stats: [numFiles=1,totalSize=89444]
OK
Time taken: 1.422 seconds<