数据库逻辑删除的sql语句_通过数据库的眼睛查询sql的逻辑流程

数据库逻辑删除的sql语句

Structured Query Language (SQL) is famously known as the romance language of data. Even thinking of extracting the single correct answer from terabytes of relational data seems a little overwhelming. So understanding the logical flow of query is very important.

小号 tructured查询语言(SQL)是著名的被称为数据的浪漫语言。 甚至想从TB的关系数据中提取单个正确答案似乎也有些不知所措。 因此,了解查询的逻辑流程非常重要。

查询执行计划 (Query Execution Plan)

SQL is a declarative language, this means SQL query logically describes the question to the SQL Query Optimizer which later decides on the best way to physically execute the query. This method of execution is called the query execution plan. There can be more than one execution plan, so when we say optimize a query that in turn referring to make the query execution plan more efficient.

SQL是一种声明性语言,这意味着SQL查询从逻辑上向SQL查询优化器描述了问题,SQL优化器随后决定了物理执行查询的最佳方法。 这种执行方法称为查询执行计划。 可以有多个执行计划,因此当我们说优化查询时,该查询反过来又使查询执行计划更有效。

Let’s look into the 2 flows that a SQL query can be looked through:

让我们看一下可以查询SQL查询的2个流程:

查询的句法流程 (Syntactical Flow of Query)

The SELECT statement basically tells the database what data to be retrieved along with which columns, rows, and tables to get the data from, and how to sort the data.

SELECT语句基本上告诉数据库要检索哪些数据以及从中获取数据的列,行和表,以及如何对数据进行排序。

Image for post
Abbreviated Syntax for the SELECT command [1]
SELECT命令的缩写语法[1]
  • SELECT statement begins with a list of columns or expressions.

    SELECT语句以列或表达式列表开头。

  • FROM portion of the SELECT statement assembles all the data sources into a result set that is used by the rest of the SELECT statement.

    SELECT语句的FROM部分将所有数据源组合成一个结果集,供其余SELECT语句使用。

  • WHERE clause acts upon the record set assembled by the FROM clause to filter certain rows based upon conditions.

    WHERE子句作用于FROM子句组合的记录集,以根据条件过滤某些行。

  • GROUP BY clause can group the larger data set into smaller data sets based on the columns specified.

    GROUP BY子句可以根据指定的列将较大的数据集分组为较小的数据集。

  • HAVING clause can be used to restrict the result of aggregation by GROUP BY.

    HAVING子句可用于限制GROUP BY的聚合结果。

  • ORDER BY clause determines the sort order of the result set.

    ORDER BY子句确定结果集的排序顺序。

Simplest possible valid SQL statement is :

最简单的有效SQL语句是:

SELECT 1; (Oracle a requires FROM DUAL appended to accomplish this)

选择1; (Oracle要求附加FROM FROM DUAL来完成此操作)

Hmmm... What is the problem in the flow of “Syntactical Flow”? Can you SELECT data without knowing WHERE it is coming FROM ?? ...Hmmm .. Somewhere there is LOGIC missing right !!! Soo ..

嗯...“句法流”中的问题是什么? 您可以在不知道数据来自何处的情况下选择数据吗? ...嗯..某个地方缺少LOGIC吧!!! o ..

Image for post
Smart on Smart在UnsplashUnsplash拍摄

查询的逻辑流程 (Logical Flow of Query)

The best way to think the SQL statement is through the query’s logical flow. Logical may not be the same as physical flow and also it is not the same as the query syntax. Think the query in the following order:

认为SQL语句的最佳方法是通过查询的逻辑流程。 逻辑可能与物理流程不同,也与查询语法不同。 按以下顺序考虑查询:

Image for post
A simplified view of Logical flow [1]
逻辑流的简化视图[1]
  1. FROM: Logically query starts from the FROM clause by assembling the initial set of data.

    FROM :逻辑查询是通过组装初始数据集从FROM子句开始的。

  2. WHERE: Then where clause is applied to select only the rows that meet the criteria.

    WHERE :然后应用where子句以仅选择满足条件的行。

  3. Aggregations: Later aggregation is performed on the data such as finding the sum, grouping the data values in columns, and filtering the groups.

    聚合 :稍后对数据执行聚合,例如查找总和,将数据值分组到列中以及过滤组。

  4. Column Expressions: After the above operations the SELECT list is processed along with calculations of any expressions involved in it. (Except column expressions everything else is optional in SQL query.)

    列表达式 :完成上述操作后,将处理SELECT列表以及其中涉及的任何表达式的计算。 (除了列表达式,SQL查询中的其他所有内容都是可选的。)

  5. ORDER BY: After getting the final resulting rows are sorted ascending or descending by ORDER BY clause.

    ORDER BY :得到最终的结果行之后,按ORDER BY子句对行进行升序或降序排序。

  6. OVER: Windowing and ranking functions can later be applied to get a separately ordered view of the result with additional functions for aggregation.

    结束:以后可以使用开窗和排名功能来获取结果的单独排序视图,并带有用于聚合的其他功能。

  7. DISTINCT: This is applied to remove any duplicate rows present in result data.

    DISTINCT :用于删除结果数据中存在的所有重复行。

  8. TOP: After all this process of selecting data filtering it and performing all the calculations and ordering them, SQL can restrict the result to top few rows.

    顶部:在完成所有这些选择数据的过程之后,对数据进行过滤并执行所有计算并对它们进行排序,SQL可以将结果限制在前几行。

  9. INSERT, UPDATE, DELETE: This is the final logical step of the query to perform data modification using the resulting output.

    INSERT,UPDATE,DELETE:这是查询的最后逻辑步骤,用于使用结果输出执行数据修改。

  10. UNION: The output from the multiple queries can be stacked to using the UNION command.

    UNION :可以使用UNION命令将多个查询的输出堆叠在一起。

For all the data anlysts who are working on database or datawarehouse projects. It is very important to understand the logical flow and the basic logic behind it. In any data anlysis project, data collection would be first step (FROM) and removing unessecarry data (WHERE) and then ordering the data (ORDER BY) follows.

对于从事数据库或数据仓库项目的所有数据分析师。 了解逻辑流程及其背后的基本逻辑非常重要。 在任何数据分析项目中,数据收集都是第一步(FROM),然后删除未保密的数据(WHERE),然后对数据进行排序(ORDER BY)。

翻译自: https://medium.com/@manoj.bidadiraju/logical-flow-of-sql-query-sql-through-the-eye-of-database-e7d111c87516

数据库逻辑删除的sql语句

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389617.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

好用的模块

import requests# 1、发get请求urlhttp://api.xxx.xx/api/user/sxx_infodata{stu_name:xxx}reqrequests.get(url,paramsdata) #发get请求print(req.json()) #字典print(req.text) #string,json串# 返回的都是什么# 返回的类型是什么# 中文的好使吗# 2、发请求posturlhttp://api…

5940. 从数组中移除最大值和最小值

5940. 从数组中移除最大值和最小值 给你一个下标从 0 开始的数组 nums ,数组由若干 互不相同 的整数组成。 nums 中有一个值最小的元素和一个值最大的元素。分别称为 最小值 和 最大值 。你的目标是从数组中移除这两个元素。 一次 删除 操作定义为从数组的 前面 …

BZOJ4127Abs——树链剖分+线段树

题目描述 给定一棵树,设计数据结构支持以下操作 1 u v d  表示将路径 (u,v) 加d 2 u v 表示询问路径 (u,v) 上点权绝对值的和 输入 第一行两个整数n和m,表示结点个数和操作数接下来一行n个整数a_i,表示点i的权值接下来n-1行,每行两个整数u,v表示存在一条(u,v)的…

数据挖掘流程_数据流挖掘

数据挖掘流程1-简介 (1- Introduction) The fact that the pace of technological change is at its peak, Silicon Valley is also introducing new challenges that need to be tackled via new and efficient ways. Continuous research is being carried out to improve th…

北门外的小吃街才是我的大学食堂

学校北门外的那些小吃摊,陪我度过了漫长的大学四年。 细数下来,我最怀念的是…… (1)烤鸡翅 吸引指数:★★★★★ 必杀技:酥流油 烤鸡翅有蜂蜜味、香辣味、孜然味……最爱店家独创的秘制鸡翅。鸡翅的外皮被…

786. 第 K 个最小的素数分数

786. 第 K 个最小的素数分数 给你一个按递增顺序排序的数组 arr 和一个整数 k 。数组 arr 由 1 和若干 素数 组成&#xff0c;且其中所有整数互不相同。 对于每对满足 0 < i < j < arr.length 的 i 和 j &#xff0c;可以得到分数 arr[i] / arr[j] 。 那么第 k 个…

[LeetCode]最长公共前缀(Longest Common Prefix)

题目描述 编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀&#xff0c;返回空字符串 ""。 示例 1:输入: ["flower","flow","flight"]输出: "fl"示例 2:输入: ["dog","racecar",&quo…

域嵌套太深_pyspark如何修改嵌套结构域

域嵌套太深In our adventures trying to build a data lake, we are using dynamically generated spark cluster to ingest some data from MongoDB, our production database, to BigQuery. In order to do that, we use PySpark data frames and since mongo doesn’t have …

redis小结

Redis 切换到redis的目录 启动&#xff1a;./redis-server 关闭&#xff1a;killall redis-server Redis的数据类型&#xff1a; String字符 list链表 set集合&#xff08;无序&#xff09; Sort Set排序&#xff08;有序&#xff09; hash数据类型 string类型的数据操作 re…

WIN10下ADB工具包安装的教程和总结 --201809

ADB&#xff08;Android Debug Bridge&#xff09;是Android SDK中的一个工具, 使用ADB可以直接操作管理Android模拟器或者真实的Andriod设备。 ADB主要功能有: 在Android设备上运行Shell(命令行)管理模拟器或设备的端口映射在计算机和设备之间上传/下载文件将电脑上的本地APK软…

1816. 截断句子

1816. 截断句子 句子 是一个单词列表&#xff0c;列表中的单词之间用单个空格隔开&#xff0c;且不存在前导或尾随空格。每个单词仅由大小写英文字母组成&#xff08;不含标点符号&#xff09;。 例如&#xff0c;“Hello World”、“HELLO” 和 “hello world hello world”…

spark的流失计算模型_使用spark对sparkify的流失预测

spark的流失计算模型Churn prediction, namely predicting clients who might want to turn down the service, is one of the most common business applications of machine learning. It is especially important for those companies providing streaming services. In thi…

峰识别 峰面积计算 peak detection peak area 源代码 下载

原文:峰识别 峰面积计算 peak detection peak area 源代码 下载Comparative analysis of peak-detection techniques for comprehensive two-dimensional chromatography http://www.docin.com/p-172045359.html http://terpconnect.umd.edu/~toh/spectrum/ipeak.html R…

区块链开发公司谈区块链与大数据的关系

在过去的两千多年的时间长河中&#xff0c;数字一直指引着我们去探索很多未知的科学世界。到目前为止&#xff0c;随着网络和信息技术的发展&#xff0c;一切与人类活动相关的活动&#xff0c;都直接或者间接的连入了互联网之中&#xff0c;一个全新的数字化的世界展现在我们的…

Jupyter Notebook的15个技巧和窍门,可简化您的编码体验

Jupyter Notebook is a browser bases REPL (read eval print loop) built on IPython and other open-source libraries, it allows us to run interactive python code on the browser.Jupyter Notebook是基于IPL和其他开源库构建的基于REPL(读取评估打印循环)的浏览器&#…

给定有权无向图的邻接矩阵如下,求其最小生成树的总权重,代码。

#include<bits/stdc.h> using namespace std; #define INF 0x3f3f3f3f const int maxn 117; int m[maxn][maxn]; int vis[maxn], low[maxn]; /* 对于这道题目来将&#xff0c;m就是临接矩阵&#xff0c;vis是访问标记数组&#xff0c;low是最短距离数组 */ int n; int …

Ubuntu-16-04-编译-Caffe-SSD

该来的还是要来 之前为了偷懒想到使用 Docker 回避 Caffe SSD 编译的难题。结果&#xff0c;「天道好轮回&#xff0c;苍天饶过谁」。Docker 镜像内无法调用 GUI 显示以及摄像头&#xff0c;没法跑 ssd_pascal_webcam.py 做实时 Object Detection。所以没办法又得重新尝试编译 …

bi数据分析师_BI工程师和数据分析师的5个格式塔原则

bi数据分析师Image by Author图片作者 将美丽融入数据 (Putting the Beauty in Data) Have you ever been ravished by Vizzes on Tableau Public that look like only magic could be in play to display so much data in such a pleasing way?您是否曾经被Tableau Public上的…

BSOJ 2423 -- 【PA2014】Final Zarowki

Description 有n个房间和n盏灯&#xff0c;你需要在每个房间里放入一盏灯。每盏灯都有一定功率&#xff0c;每间房间都需要不少于一定功率的灯泡才可以完全照亮。 你可以去附近的商店换新灯泡&#xff0c;商店里所有正整数功率的灯泡都有售。但由于背包空间有限&#xff0c;你…

WPF绑定资源文件错误(error in binding resource string with a view in wpf)

报错&#xff1a;无法将“***Properties.Resources.***”StaticExtension 值解析为枚举、静态字段或静态属性 解决办法&#xff1a;尝试右键单击在Visual Studio解决方案资源管理器的资源文件&#xff0c;并选择属性选项&#xff0c;然后设置自定义工具属性 PublicResXFile cod…