自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(69)
  • 收藏
  • 关注

原创 PTA 1010 一元多项式求导

{ //EOF是行末的意思,意思就是这一行还有东西就继续。//n==0 说明是常数,不需要求导。=EOF)//就是导数公式。

2024-03-02 19:39:58 448 1

原创 PTA 1009 说反话

【代码】PTA 1009 说反话。

2024-03-02 18:27:00 345

原创 PTA 1008 数组元素循环右移问题

【代码】PTA 1008 数组元素循环右移问题。

2024-03-02 17:39:05 660

原创 PTA 1007 素数对猜想

【代码】PTA 1007 素数对猜想。

2024-03-02 17:38:30 311

原创 PTA 1006 换个格式输出整数

【代码】PTA 1006 换个格式输出整数。

2024-03-02 17:37:38 323

原创 PTA 1005 继续(3n+1)猜想

【代码】PTA 1005 继续(3n+1)猜想。

2024-03-02 17:37:01 361

原创 PTA 1004 成绩排名

【代码】PTA 1004 成绩排名。

2024-03-02 17:35:51 314

原创 PTA 1003 我要通过!

【代码】PTA 1003 我要通过!

2024-03-02 17:34:56 310

原创 PTA 1002 写出这个数

【代码】PTA 1002 写出这个数。

2024-03-02 17:34:03 317

原创 PTA 1001 害死人不偿命的(3n+1)猜想

【代码】PTA 1001 害死人不偿命的(3n+1)猜想。

2024-03-02 17:33:19 286

原创 MYSQL 寒假自学 2022 十三 (一)

视图部分数据准备create database if not exists mydb6_view;use mydb6_view;create table dept( deptno int primary key, dname varchar(20), loc varchar(20));insert into dept values(10, '教研部','北京'),(20, '学工部','上海'),(30, '销售部','广州'),(40, '财务部','武汉');crea

2022-02-20 22:43:42 260

原创 MYSQL 寒假自学 2022 十二 (十二)

-- 第几个值select dname, ename, salary, hiredate, nth_value(salary,2) over(partition by dname order by hiredate)as second_salary, nth_value(salary,3) over(partition by dname order by hiredate )as third_salaryfrom employee;-- 分等级select dname, e.

2022-02-20 16:31:51 343

原创 MYSQL 寒假自学 2022 十二 (十一)

-- 头尾函数,到当前行,为止select dname, ename, salary, hiredate, first_value(salary) over(partition by dname order by hiredate)as first, last_value(salary) over(partition by dname order by hiredate )as lastfrom employee;

2022-02-20 16:12:14 269

原创 MYSQL 寒假自学 2022 十二 (十)

-- 前后函数 lag和leadselect dname, ename, salary, hiredate, lag(hiredate,1,'2000-01-01') over(partition by dname order by hiredate)as time1, lag(hiredate,2) over(partition by dname order by hiredate )as time2from employee;select dname, ename, sa.

2022-02-20 16:02:09 343

原创 MYSQL 寒假自学 2022 十二 (九)

use mydb4;select dname, ename, salary, cume_dist() over(order by salary) as rn1, cume_dist() over(partition by dname order by salary) as rn2from employee;#小于等于该值的,然后除以总行数分布函数 cume_dist()

2022-02-20 15:29:15 55

原创 MYSQL 寒假自学 2022 十二 ( 八)

use mydb4;select dname, ename, hiredate, salary, sum(salary) over (partition by dname order by hiredate) as pv1from employee;select dname, ename, hiredate, salary, sum(salary) over (partition by dname ) as pv1from employee;# 将order by 删去.

2022-02-18 23:29:25 128

原创 MYSQL 寒假自学 2022 十二 (七)

use mydb4;create table employee( dname varchar(20), #部门名 eid varchar(20), ename varchar(20), hiredate date, #入职日期 salary double #薪资);insert into employee values('研发部','1001','刘备','2021-11-01',3000);insert into employee values('研发部','1002','关羽','.

2022-02-17 00:21:45 266

原创 MYSQL 寒假自学 2022 十二 (六)

-- 控制流函数-- ifselect if(5>3,'大于','小于');use mydb3;select *,if(score>=85,'优秀','及格') flag from score;-- ifnullselect ifnull(5,0);use test1;select *,ifnull(comm,0) comm_flag from emp;-- 是null为1,不是null为0select isnull(5);select isnull(null);.

2022-02-16 18:02:24 233

原创 MYSQL 寒假自学 2022 十二 (五)

图片来自(46条消息) mysql输出当前是第几周使用week和weekofyear的区别_八碗清水的博客-CSDN博客-- 日期函数-- 1,获取时间戳(毫秒值)select unix_timestamp();-- 2,将一个日期字符串转为毫秒值select unix_timestamp('2021-12-21 08:08:08');-- 3,将时间戳毫秒值转为指定格式的日期select from_unixtime(1640045288,'%Y-%m-%d %H:%i:%s')...

2022-02-15 23:11:44 274

原创 MYSQL 寒假自学 2022 十二 (四)

-- 9,返回字符串的后几个字符select right('hello',3); #llo-- 10,字符串比较select strcmp('hello','world'); #-1select strcmp('aaa','aaa'); # 0select strcmp('aaad','aba'); #-1select strcmp('b','a'); #1-- 11,字符串截取select substr('hello',2,3); #ellselect substring('...

2022-02-15 18:24:20 151

原创 MYSQL 寒假自学 2022 十二 (三)

-- 字符串函数-- 1,获取字符串字符个数select char_length('hello '); #6空格也算select char_length('你好吗'); #3 汉字算一个-- charactr_length 和char_length 的功能相同-- length 取长度,返回的单位是字节select length('hello '); #6select length('你好吗'); #9 UTF-8编码中,汉字占三个字节-- 2,字符串合并select concat(.

2022-02-15 01:32:28 52

原创 MYSQL 寒假自学 2022 十二 (二)

-- 绝对值select abs(-10);#10select abs(10);#10select abs(-1.1);#1.1-- ceil 向上取整select ceil(1.1);#2select ceil(-1.1);#-1-- floor 向下取整select floor(1.1);#1select floor(-1.1);#-2-- 取列表最大值select greatest(1,2,3);select greatest(1.1,2,3);-- 取列表最小值.

2022-02-14 19:09:45 137

原创 MYSQL 寒假自学 2022 十二 (一)

函数group_concat数据准备create database mydb4;use mydb4;create table emp( emp_id int primary key auto_increment comment '编号', emp_name char(20) not null default '' comment '姓名', salary decimal(10,2) not null default 0 comment '工资', department char

2022-02-14 17:24:35 181

原创 MYSQL 寒假自学 2022 十一(十)

-- 练习-- 1,返回拥有员工的部门名,部门号select distinct dname,dept.deptno from dept join emp on dept.deptno = emp.deptno;-- 2,工资水平多于smith的员工信息select * from emp where sal > (select sal from emp where ename = 'smith');-- 3,返回员工和所属经理的名字select a.ename,b.ename from.

2022-02-14 01:29:41 265

原创 MYSQL 寒假自学 2022 十一(九)

多表查询练习的代码准备工作-- 创建test1数据库create database test1;-- 选择使用test1数据库use test1;-- 创建部门表create table dept( deptno int primary key comment '部门编号', dname varchar(14) comment '部门名称', loc varchar(13) comment '部门地址');insert into dept values(10,'account

2022-02-14 00:23:45 97

原创 MYSQL 寒假自学 2022 十一(九)

自关联查询mysql有时在信息查询时需要进行对表自身进行关联查询,即一张表自己和自己关联,一张表当成多张表来用。注意自关联时必须给表起别名。准备工作use mydb3;create table t_sanguo( eid int primary key, ename varchar(20), manager_id int, foreign key (manager_id) references t_sanguo(eid) #添加自关联查询);insert into t_sa

2022-02-13 22:59:30 102

原创 MYSQL 寒假自学 2022 十一(八)

-- 查询公司是否有大于60岁的员工,有则输出select * from emp3 where exists(select * from emp3 where age > 60);#错误写法,为全表输出select * from emp3 a where exists(select * from emp3 b where a.age > 60);select * from emp3 where eid in (select eid from emp3 where age > .

2022-02-13 18:02:55 153

原创 MYSQL 寒假自学 2022 十一(七)

-- 查询研发部和销售部的员工信息,包含员工号、员工名字select eid,ename from emp3 where dept_id in(select deptno from dept3 where name = '研发部' or name = '销售部');

2022-02-13 17:09:09 117

原创 MYSQL 寒假自学 2022 十一(六)

-- 查询年龄大于‘1003’部门任意一个员工年龄的员工信息select * from emp3 where age > any (select age from emp3 where dept_id = '1003') and dept_id !='1003';#把10003部门的给去掉#some 和 any 的用法一样,可以理解为some是any的别名...

2022-02-13 16:24:50 129

原创 MYSQL 寒假自学 2022 十一(五)

子查询的关键字all any some in existsuse mydb3;-- 查询年龄大于'1003'部门所有年龄的员工信息select * from emp3 where age > all (select age from emp3 where dept_id = '1003');-- 查询不属于任何一个部门的员工信息select * from emp3 where dept_id != all (select deptno from dept3); ...

2022-02-13 15:55:10 55

原创 MYSQL 寒假自学 2022 十一(四)

-- 子查询/*子查询就是指在一个完整的查询语句中,嵌套若干个不同功能的小查询,从而一起完成复杂查询的一种编写方式,通俗一点就是包含select嵌套的查询*/-- 查询年龄最大的员工信息,显示信息包好员工号,员工名字,员工年龄select * from emp3 where age = (select max(age) from emp3); #单行单列,可以作为一个值来使用-- 查询研发部和销售部的员工信息,包含员工号,员工名字-- 方法一,使用多表查询select * from dep.

2022-02-12 14:27:11 454

原创 MYSQL 寒假自学 2022 十一(三)

外连接查询外连接分为左外连接(left outer join),右外连接(right outer join),满外连接(full outer join)hit: oracle 里面有full join,可是在mysql对full join支持的不好,我们可以使用union来达到目的晚上七点了,先吃饭去...

2022-02-11 19:17:03 88

原创 MYSQL 寒假自学 2022 十一(二)

交叉连接查询select * from dept3,emp3;得到结果如下还有很多,只截取了一部分。内连接查询实际上,内连接查询求的是两张表的交集。-- 隐式内连接(SQL92标准):select * from dept3,emp3 where dept3.deptno = emp3.dept_id;-- 显示内连接(SQL99标准):select * from dept3 inner join emp3 on dept3.deptno=emp3.dept_id;

2022-02-11 14:10:17 91

原创 MYSQL 寒假自学 2022 十一(一)

多表联合查询的准备工作use mydb3;create table if not exists dept3( deptno varchar(20), name varchar(20));create table if not exists emp3( eid varchar(20) primary key, ename varchar(20), age int, dept_id varchar(20));insert into dept3 values('1001','研发

2022-02-11 12:11:46 279

原创 MYSQL 寒假自学 2022 十(四)

-- 外键约束 多对多关系-- 创建学生表和课程表 (左侧主表和右侧主表)use mydb3;create table student( sid int primary key auto_increment, name varchar(20), age int, gender varchar(20));create table course( cid int primary key auto_increment, cidname varchar(20));create .

2022-02-10 13:13:49 167

原创 MYSQL 寒假自学 2022 十(三)

alter table emp2 drop foreign key emp2_fk;删除外键约束注意要查看外键的名删除过后二者没有联系

2022-02-10 00:00:06 184

原创 MYSQL 寒假自学 2022 十(二)

use mydb3;-- 添加主表数据-- 注意必须献给主表添加数据insert into dept values('1001','研发部');insert into dept values('1002','销售部');insert into dept values('1003','财务部');insert into dept values('1004','人事部');-- 添加从表数据-- 注意给从表添加数据时,外键列的值不能随便写,必须依赖主表的主键列insert into emp.

2022-02-09 19:25:05 193

原创 MYSQL 寒假自学 2022 十(一)

create database mydb3;use mydb3;create table if not exists dept( detpno varchar(20) primary key, name varchar(20));create table if not exists emp( eid varchar(20) primary key, ename varchar(20), age int, dept_id varchar(20), constraint emp_f.

2022-02-09 14:37:41 203

原创 MYSQL 寒假自学 2022 九(二)

use mydb2;-- a1|a2 匹配a1或者a2select 'a' regexp 'a|b';select 'b' regexp 'a|b';select 'b' regexp '^(a|b)';-- 以a,或者b开头select 'a' regexp '^(a|b)';select 'c' regexp '^(a|b)';-- a{m} 匹配m个aselect 'auuuuc' regexp 'au{4}c';select 'auuuuc' regexp 'au{3}c';.

2022-02-07 12:35:11 297

原创 MYSQL 寒假自学 2022 九(一)

正则表达式-- 在字符串开始处进行匹配select 'abc' regexp '^a';-- 在字符串末尾开始匹配select 'abc' regexp 'a$';select 'abc' regexp 'c$';-- 匹配任意单个字符select 'abc' regexp '.b'; -- 1select 'abc' regexp '.c'; -- 1select 'abc' regexp 'a.'; -- 1-- [...] 匹配括号内任意单个字符select 'abc

2022-02-06 23:49:33 251

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除