当前位置:网站首页>SQL 速查
SQL 速查
2020-11-08 16:57:00 【程序猿欧文】

- 关系数据库,基于关系模型,使用关系(表)存储数据,同时定义了完整性约束。常见的关系数据库系统包括:Oracle、MySQL/MariaDB、SQL Server、PostgreSQL 等等。
- SQL,结构化查询语言,访问和操作关系数据库的标准语言。SQL 具有声明性,是一种面向集合的编程语言。
1、单表查询
SELECT col1, col2 AS c2 -- 列别名 FROM t; -- 基本查询SELECT * FROM t; -- 查询所有字段SELECT col1, col2, … FROM t WHERE conditions; -- 过滤条件SELECT col1, col2, … FROM t ORDER BY col1 ASC, col2 DESC; -- 排序SELECT col1, col2, … FROM t ORDER BY col1 ASC, col2 DESC OFFSET m ROWS FETCH FIRST n ROWS ONLY; -- 限定数量 LIMIT n OFFSET m; -- 非标准实现SELECT col1, col2, agg_fun() -- 聚合函数 FROM t GROUP BY col1, col2 -- 分组汇总 HAVING conditions; -- 分组后过滤
2、多表连接
SELECT t1.col1, t2.col2, … FROM t1 INNER JOIN t2 ON conditions; -- 内连接 SELECT t1.col1, t2.col2, … FROM t1 LEFT JOIN t2 ON conditions; -- 左连接SELECT t1.col1, t2.col2, … FROM t1 RIGHT JOIN t2 ON conditions; -- 右连接SELECT t1.col1, t2.col2, … FROM t1 FULL JOIN t2 ON conditions; -- 全连接SELECT t1.col1, t2.col2, … FROM t1 CROSS JOIN t2 ON conditions;-- 交叉连接SELECT a.col1, b.col2, … FROM t1 a -- 表别名 JOIN t1 b ON conditions; -- 自连接
3、集合运算
SELECT col1, col2, … FROM t1 UNION [ALL]SELECT c1, c2, … FROM t2; -.........
版权声明
本文为[程序猿欧文]所创,转载请带上原文链接,感谢
https://my.oschina.net/mikeowen/blog/4708273
边栏推荐
- 喜获蚂蚁offer,定级p7,面经分享,万字长文带你走完面试全过程
- Flink的sink实战之一:初探
- IT行业薪资一直遥遥领先!十年后的程序员,是否还是一个高薪职业?
- Tencent: Although Ali's Taichung is good, it is not omnipotent!
- AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
- Golang system ping program to detect the surviving host (any permission)
- TypeScript(1-2-2)
- LiteOS-消息队列
- 学习记录并且简单分析
- What are the necessary laws and regulations to know when entering the Internet?
猜你喜欢
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
c++ opencv4.3 sift匹配
Build simple business monitoring Kanban based on Alibaba cloud log service
python开发qt程序读取图片的简单流程
experiment
Gopherchina 2020 Conference
IT行业薪资一直遥遥领先!十年后的程序员,是否还是一个高薪职业?
Python 列表的11个重要操作
Alibaba cloud accelerates its growth and further consolidates its leading edge
. net large data concurrency solution
随机推荐
Xiaoqingtai officially set foot on the third day of no return
Jsliang job series - 07 - promise
C++的那些事儿:从电饭煲到火箭,C++无处不在
The first open source Chinese Bert pre training model in the financial field
Mac环境安装Composer
浅谈,盘点历史上有哪些著名的电脑病毒,80%的人都不知道!
Design by contract (DBC) and its application in C language
AI weekly: employees are allowed to voluntarily reduce salary; company response: employees are happy and satisfied; tiger tooth HR takes employees out of the company; Sweden forbids Huawei ZTE 5g equi
性能压测时,并发压力增加,系统响应时间和吞吐量如何变化
AI perfume is coming. Will you buy it?
Liteos message queuing actual combat
框架-SPI四种模式+通用设备驱动实现-源码
Js中常见的内存泄漏场景
Interpretation of deepmind's latest paper: the causal reasoning algorithm in discrete probability tree is proposed for the first time
c++ opencv4.3 sift匹配
2020-11-05
(O) Analysis of service manager (1) BinderInternal.getContextObject
Blockchain weekly: the development of digital currency is written into the 14th five year plan; Biden invited senior adviser of MIT digital currency program to join the presidential transition team; V
I used Python to find out all the people who deleted my wechat and deleted them automatically
Talk about go code coverage technology and best practices