随笔分类 -  sql

摘要:转载: https://blog.csdn.net/diyangxia/article/details/122208764 阅读全文
posted @ 2023-02-07 14:46 Jasmine_Lee 阅读(25) 评论(0) 推荐(0) 编辑
摘要:转载:https://www.cnblogs.com/nanblog/p/16393646.html 阅读全文
posted @ 2023-02-07 14:24 Jasmine_Lee 阅读(55) 评论(0) 推荐(0) 编辑
摘要:转载:https://www.modb.pro/db/224185 阅读全文
posted @ 2023-02-07 13:59 Jasmine_Lee 阅读(19) 评论(0) 推荐(0) 编辑
摘要:https://blog.csdn.net/u011944141/article/details/78927715 https://www.linuxidc.com/Linux/2015-04/116349.htm Oracle中rank() over, dense_rank(), row_numb 阅读全文
posted @ 2022-11-18 14:20 Jasmine_Lee 阅读(488) 评论(0) 推荐(0) 编辑
摘要:1. in和exists in 是把外表和内表作hash连接, exists 是对外表作loop循环,每次loop循环再对内表进行查询,一直以来认为exists比in效率高的说法是不准确的。 如果查询的两个表大小相当,那么用in和exists差别不大;如果两个表中一个较小一个较大,则子查询表大的用e 阅读全文
posted @ 2022-11-03 17:39 Jasmine_Lee 阅读(1890) 评论(0) 推荐(1) 编辑
摘要:select 1 和select * select * from 表;查询出表中所有数据,性能比较差; select 常量 from 表;查询出结果是所有记录数的常量,性能比较高; selelct 常量 from ... 对应所有行,返回的永远只有一个值,即常量。例如 select 1 from 表 阅读全文
posted @ 2022-11-03 17:18 Jasmine_Lee 阅读(496) 评论(0) 推荐(0) 编辑
摘要:(64条消息) SQL查询-存在一个表而不在另一个表中的数据_请加油吧的博客-CSDN博客 SQL查询-存在一个表而不在另一个表中的数据 方法1:使用not in 容易理解,效率低,执行时间为1.395s select distinct a.id from a where a.id not in ( 阅读全文
posted @ 2022-10-20 10:09 Jasmine_Lee 阅读(738) 评论(0) 推荐(0) 编辑
摘要:SQL行转列,列转行 - 简书 (jianshu.com) 阅读全文
posted @ 2022-09-14 16:09 Jasmine_Lee 阅读(19) 评论(0) 推荐(0) 编辑
摘要:转载: mysql 实现lag() over (partition by order by) - 简书 (jianshu.com) 阅读全文
posted @ 2022-08-30 17:18 Jasmine_Lee 阅读(363) 评论(0) 推荐(0) 编辑
摘要:sql查询 —— 分组 1 -- 分组 2 -- group by 3 -- 分组只有与聚合函数一起使用才能发挥作用 4 -- 分组只限于字段分明 例如 性别 ,部门, 5 --列出所有性别 6 select gender from student group by gender; 7 --列出所有 阅读全文
posted @ 2022-01-08 11:56 Jasmine_Lee 阅读(503) 评论(0) 推荐(0) 编辑
摘要:数据库的隔离级别: 1. 对于同时运行的多个事务,当这些事务访问数据库中相同的数据时,如果没有必要的隔离级别,就会导致各种并发问题: 脏读:对于两个事务T1,T2,T1,读取了已经被T2更新单还没有被提交的字段之后,若T2回滚,T1读取的内容就是临时的,无效的。(一个事务读取了其他事务没有提交的数据 阅读全文
posted @ 2020-04-24 17:09 Jasmine_Lee 阅读(104) 评论(0) 推荐(0) 编辑
摘要:事务控制语言(Transaction Control Language): 事务:一个或一组SQL语句组成一个执行单元,这个执行单元要么全部执行,要么全部不执行。 案例:转账 张三丰 1000 郭襄1000元 update 表 set 张三丰的月=500 where name='张三丰'; upda 阅读全文
posted @ 2020-04-24 16:26 Jasmine_Lee 阅读(198) 评论(0) 推荐(0) 编辑
摘要:数据类型介绍 一、整型 数据类型 字节 存储范围 Tinyint 1 有符号值:-128~127() 无符号值:0~255 Smallint 2 有符号值:-32768~32767 无符号值:0~65535 Mediumint 3 有符号值:-8388608~8388607 无符号值:0~16772 阅读全文
posted @ 2020-04-17 17:34 Jasmine_Lee 阅读(216) 评论(0) 推荐(0) 编辑
摘要:表的管理 1. 表的创建 create table if not exists 表名( 列名 列的类型(长度)约束, 列名 列的类型(长度)约束 ); 列的类型长度和约束可以省略 案例1. 创建表book create table if not exists book( id int, #书的编号 阅读全文
posted @ 2020-04-17 14:44 Jasmine_Lee 阅读(155) 评论(0) 推荐(0) 编辑
摘要:库的管理 1. 库的创建 create database if not exists 库名; 例:创建库books create database if not exists books; 2. 库的修改 更改库名直接到文件夹里重命名,没有直接的sql语句 更改库的字符集 alter databas 阅读全文
posted @ 2020-04-16 17:03 Jasmine_Lee 阅读(108) 评论(0) 推荐(0) 编辑
摘要:删除语句 语法:方式一 delete from 表名 where 筛选条件(删除整行) 单表的删除 1. delete from 表名 where 筛选条件 案例:删除手机号以9结尾的女神信息 delete from beauty where phone like '%9'; 2. 多表的删除 ①s 阅读全文
posted @ 2020-04-16 16:44 Jasmine_Lee 阅读(164) 评论(0) 推荐(0) 编辑
摘要:修改语句 update 表名 set 列=新值,列=新值 where 筛选条件; 注意:字符型,日期型要加引号 修改单表 案例1:修改beauty中姓唐的女神的电话为13899888899 update beauty set phone='13899888899' where name like ' 阅读全文
posted @ 2020-04-16 15:15 Jasmine_Lee 阅读(163) 评论(0) 推荐(0) 编辑
摘要:一、插入语言 语法: 方式一较常用 insert into 表名(列名,.....) values (值1,值2,.....) , #第一行数据 (值3,值4,.....) , #第二行数据 . #第三行数据 . . #第n行数据 ; 注意: 1. 插入的值的类型要与列的类型一致或兼容 insert 阅读全文
posted @ 2020-04-16 14:50 Jasmine_Lee 阅读(156) 评论(0) 推荐(0) 编辑
摘要:联合查询 关键词:union 联合,合并;将多条查询语句的结果合并成一个结果 语法:查询语句1 union 查询语句2 union...... 应用场景:要查询的结果来自于多个表 且 多个表没有直接的连接关系,但查询的信息一致时 案例:查询部门编号>90号或邮箱中包含a的员工信息 ①:以前的方式 s 阅读全文
posted @ 2020-04-14 17:07 Jasmine_Lee 阅读(97) 评论(0) 推荐(0) 编辑
摘要:#1.查询工资最低的员工信息:last_name,salary select last_name,salary from employees where salary is not null order by salary limit 1; 或 select last_name, salary fr 阅读全文
posted @ 2020-04-14 15:45 Jasmine_Lee 阅读(109) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示