当前位置:网站首页>SQL 速查
SQL 速查
2020-11-08 16:57:00 【程序猿欧文】
1、说明:创建数据库CREATE DATABASE database-name2、说明:删除数据库drop database dbname3、说明:备份sql server--- 创建 备份数据的 deviceUSE masterEXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'--- 开始 备份BACKUP DATABASE pubs T
- 关系数据库,基于关系模型,使用关系(表)存储数据,同时定义了完整性约束。常见的关系数据库系统包括: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
边栏推荐
- 10 common software architecture patterns
- c++ opencv4.3 sift匹配
- markdown使用
- AI perfume is coming. Will you buy it?
- Summary: in October, more investment management strategies have come to the new overseas defi project!
- WebGL 水波及焦散(刻蚀)的渲染总结
- Use markdown
- IT industry salary has been far ahead! Ten years later, is the programmer still a high paying profession?
- Rabbitmq (1) - basic introduction
- 构建者模式(Builder pattern)
猜你喜欢

契约式设计(Dbc)以及其在C语言中的应用

GopherChina 2020大会

刚刚好,才是最理想的状态

experiment

How to solve the conflict when JD landed on Devops platform?

Improvement of maintenance mode of laravel8 update
![[开源] .Net 使用 ORM 访问 华为GaussDB数据库](/img/f8/50715c25a9d49b010cba2ff442c04e.jpg)
[开源] .Net 使用 ORM 访问 华为GaussDB数据库

Liteos message queuing

Function classification big PK! How to use sigmoid and softmax respectively?

Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
随机推荐
Returning to the third place in the world, what did Xiaomi do right?
awk实现类sql的join操作
CSP考试须知与各种小技巧
Your random IO hard disk
AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
I used Python to find out all the people who deleted my wechat and deleted them automatically
Don't release resources in finally, unlock a new pose!
总结: 10月海外DeFi新项目,更多资管策略来了!
How to make a correct summary for 7 years?
.NET 大数据量并发解决方案
Learn to record and analyze
Comics: looking for the best time to buy and sell stocks
uni-app实战仿微信app开发
小青台正式踏上不归路的第3天
laravel8更新之速率限制改进
喜获蚂蚁offer,定级p7,面经分享,万字长文带你走完面试全过程
实验
Simple process of reading pictures by QT program developed by Python
使用K3S创建本地开发集群
Use markdown