首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
基础学习课
实战项目课
求职辅导课
专栏&文章
竞赛
搜索
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
AI面试、笔试、校招、雇品
HR免费试用AI面试
最新面试提效必备
登录
/
注册
犯困的独行侠在抱佛脚
获赞
17
粉丝
0
关注
14
看过 TA
11
女
西安交通大学
2026
数据分析师
IP属地:陕西
暂未填写个人简介
私信
关注
拉黑
举报
举报
确定要拉黑犯困的独行侠在抱佛脚吗?
发布(76)
评论
刷题
收藏
犯困的独行侠在抱佛脚
关注TA,不错过内容更新
关注
2025-06-12 10:32
西安交通大学 数据分析师
题解 | 将titles_test表名修改为titles_2017
alter table titles_test rename to titles_2017; 或者 rename table titles_test to titles_2017;
0
点赞
评论
收藏
分享
2025-06-12 10:24
西安交通大学 数据分析师
题解 | 将id=5以及emp_no=10001的行数据替换成id=5以及emp_no=10005
replace into titles_test(id,emp_no,title,from_date,to_date) select 5,10005,title,from_date,to_date from titles_test where id=5 and emp_no=10001; 或者 update titles_test set emp_no=10005 where id=5 and emp_no=10001; replace是先删除再修改,update是直接修改
0
点赞
评论
收藏
分享
2025-06-12 10:13
西安交通大学 数据分析师
题解 | 将所有to_date为9999-01-01的全部更新为NULL
update titles_test set from_date='2001-01-01',to_date=null where to_date='9999-01-01';
0
点赞
评论
收藏
分享
2025-06-11 14:07
西安交通大学 数据分析师
题解 | 删除emp_no重复的记录,只保留最小的id对应的记录。
delete t1 from titles_test t1 inner join titles_test t2 where t1.emp_no=t2.emp_no and t1.id>t2.id; delete from titles_testwhere id not in ( select min(id) from titles_test group by emp_no);这种是不行的,MySQL 不允许在 DELETE 或 UPDATE 语句的子查询中直接引用正在修改的表,这是为了防止不确定的读取行为。
0
点赞
评论
收藏
分享
2025-06-11 13:47
西安交通大学 数据分析师
题解 | 构造一个触发器audit_log
create trigger audit_log after insert on employees_test for each row begin insert into audit(emp_no,name) values(new.id,new.name); end; 第一次了解触发器的东西,要注意values后面要加分号;
0
点赞
评论
收藏
分享
2025-06-11 11:44
西安交通大学 数据分析师
题解 | 在last_update后面新增加一列名字为create_date
alter table actor add column create_date datetime not null default '2020-10-01 00:00:00' after last_update;
0
点赞
评论
收藏
分享
2025-06-11 11:22
西安交通大学 数据分析师
题解 | 针对上面的salaries表emp_no字段创建索引idx_emp_no
#create index idx_emp_no on salaries(emp_no); select * from salaries force index (idx_emp_no) where emp_no=10005;
0
点赞
评论
收藏
分享
2025-06-11 11:11
西安交通大学 数据分析师
题解 | 针对actor表创建视图actor_name_view
create view actor_name_view as select first_name first_name_v,last_name last_name_v from actor;
0
点赞
评论
收藏
分享
2025-06-09 13:38
西安交通大学 数据分析师
题解 | 对first_name创建唯一索引uniq_idx_firstname
alter table actor add unique index uniq_idx_firstname(first_name); alter table actor add index idx_lastname(last_name);
0
点赞
评论
收藏
分享
2025-06-09 11:39
西安交通大学 数据分析师
题解 | 创建一个actor_name表
create table actor_name( first_name varchar(45) not null comment '名字', last_name varchar(45) not null comment '姓氏' ); insert into actor_name(first_name,last_name) select first_name,last_name from actor;
0
点赞
评论
收藏
分享
2025-06-09 11:05
西安交通大学 数据分析师
题解 | 批量插入数据,不使用replace操作
insert ignore into actor values('3','ED','CHASE','2006-02-15 12:34:33');
0
点赞
评论
收藏
分享
2025-06-09 10:51
西安交通大学 数据分析师
题解 | 批量插入数据
insert into actor(actor_id,first_name,last_name,last_update) values('1','PENELOPE','GUINESS','2006-02-15 12:34:33'), ('2','NICK','WAHLBERG','2006-02-15 12:34:33');
0
点赞
评论
收藏
分享
2025-06-09 09:42
西安交通大学 数据分析师
将employees表的所有员工的last_name和first_name拼接起来
select concat(last_name,' ',first_name) as Name from employees;
0
点赞
评论
收藏
分享
2025-06-09 09:08
西安交通大学 数据分析师
题解 | 使用子查询的方式找出属于Action分类的所有电影对应的title,description
select title,description from film as f inner join (select film_id,name from category as c inner join film_category as fc on c.category_id=fc.category_id) as film_c on f.film_id=film_c.film_id where name='Action';
0
点赞
评论
收藏
分享
2025-06-06 14:16
西安交通大学 数据分析师
题解 | 使用join查询方式找出没有分类的电影id以及名称
select f.film_id as film_id,title from film as f left join film_category as fc on f.film_id=fc.film_id left join category as c on c.category_id=fc.category_id where c.category_id is null;
0
点赞
评论
收藏
分享
1
2
3
4
5
6
创作者周榜
更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务