请写出在Hive CLI中完成以下任务的命令行:①在路 径/data创建数据库datas,②模糊查询匹配data的 数据库,③查看datas数据库的详细信息,④使用数据 库datas,⑤创建student表,分为姓名、入学日期、 年龄三个字段,字段格式以,'分割,⑥将本地文件 student_log3.log文件数据加载到student表里,⑦ 查看student表数据前十条,@将hdfs 的/user/student_log2.log文件数据加载到student表 里,⑦查看student表数据的总条数,@查询年龄大 于18小于20点学生信息
时间: 2024-03-24 16:39:58 浏览: 111
好的,以下是在Hive CLI中完成这些任务的命令行:
①创建数据库datas:
```
CREATE DATABASE datas LOCATION '/data';
```
②模糊查询匹配data的数据库:
```
SHOW DATABASES LIKE '*data*';
```
③查看datas数据库的详细信息:
```
DESCRIBE DATABASE datas;
```
④使用数据库datas:
```
USE datas;
```
⑤创建student表,分为姓名、入学日期、年龄三个字段,字段格式以,'分割:
```
CREATE TABLE student(name STRING, enroll_date STRING, age INT)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
```
⑥将本地文件student_log3.log文件数据加载到student表里:
```
LOAD DATA LOCAL INPATH '/path/to/student_log3.log' INTO TABLE student;
```
⑦查看student表数据前十条:
```
SELECT * FROM student LIMIT 10;
```
⑧将hdfs的/user/student_log2.log文件数据加载到student表里:
```
LOAD DATA INPATH '/user/student_log2.log' INTO TABLE student;
```
⑨查看student表数据的总条数:
```
SELECT COUNT(*) FROM student;
```
⑩查询年龄大于18小于20点学生信息:
```
SELECT * FROM student WHERE age > 18 AND age < 20;
```
注意:这些命令都需要根据实际情况进行调整,例如文件路径、表名等等。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20250102104920.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231044901.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045021.png)
![-](https://img-home.csdnimg.cn/images/20241231044833.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)