Mysql、Hive语法对比

这篇博客对比了Mysql和Hive在创建学生、教师、课程和成绩表的语法差异,并展示了如何在两者中导入数据。还提供了一些SQL练习题和答案,涉及查询教师信息、学生性别统计、课程选修情况等。
摘要由CSDN通过智能技术生成

Mysql 
——————学生表——----
CREATE table student(
student_id varchar(4) ---学生编号
,name      varchar(20) ---学生姓名
,birthday  varchar(10) ---学生生日
,sex       varchar(2) ---学生性别
);

CREATE TABLE `student` (
  `student_id` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `birthday` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sex` varchar(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

HIVE
——————学生表——————
create table study.student (
     student_id   string  -- 学生编号
    ,name         string  -- 学生姓名
    ,birthday     string  -- 学生生日
    ,sex          string  -- 学生性别
)
stored as parquet
tblproperties("orc.compress"="snappy");


Mysql 
——————教师表——----
CREATE table teacher(
teacher_id varchar(4) 
,name      varchar(20) 
);

HIVE
——————教师表——————
create table study.teacher (
     teacher_id   string  -- 教师编号
    ,name         string  -- 教师姓名
)
stored as parquet
tblproperties("orc.compress"="snappy");


Mysql 
——————课程表——----
CREATE table course(
course_id   varchar(4) 
,name       varchar(20) ,teacher_id varchar(4) 
);

HIVE
——————课程表——————

create table study.course (
     course_id    string  -- 课程编号
    ,name         string  -- 课程名
    ,teacher_id   string  -- 课程对应的教师编号
)
stored as parquet
tblproperties("orc.compress"="snappy");


Mysql 
——————成绩表——----
CREATE table score(
 student_id  varchar(4)
,course_id   varchar(4) 
,score       int
);

Hive
——————成绩表——----

create table study.score (
     student_id   string  -- 学生编号
    ,course_id    string  -- 课程编号
    ,score        int     -- 对应的成绩
)
stored as parquet
tblproperties("orc.compress"="snappy");

答题时请注意&

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值