SQL专项练习11

将学生信息表的班级列默认值设为“暂未输入”

alter table 表名 modify 列名 数据类型default '默认值'

ALTER TABLE student MODIFY class CHAR(10) DEFAULT '暂未输入';

创建视图

create view 视图名 as select ....

MySQL 8.0. 不支持 full join

('1004' , '张三' ,'2000-08-06' , '男'); ('1009' , '李四', '2000-01-01', '男');

('1010' , '李四', '2001-01-01', '男'); ('1013' , '赵六' ,'2000-09-06' , '男');

('1006' , '王五', '2000-08-06' , '女'); ('1008' , '张三', '2002-12-01', '女');

('1012' , '张三', '2001-12-01', '女'); ('1011' , '李四', '2002-08-06' , '女');

select t1.*,t2.*
from (
select * from student_table where sex = '男' ) t1 
full join 
(select * from student_table where sex = '女')t2 
on  t1.name = t2.name ; 

# 等价于

select t1.*,t2.*
from (
select * from student_table where sex = '男' ) t1
right join
(select * from student_table where sex = '女')t2
on t1.name = t2.name

union all

select t1.*,t2.*
from (
select * from student_table where sex = '男' ) t1
left join
(select * from student_table where sex = '女')t2
on t1.name = t2.name

where t2.name is null ;

SQL专项练习 文章被收录于专栏

SQL专项每日练习,错题

全部评论

相关推荐

06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务