数据库逻辑删除的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,一经查实,立即删除!

相关文章

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

数据挖掘流程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)烤鸡翅 吸引指数:★★★★★ 必杀技:酥流油 烤鸡翅有蜂蜜味、香辣味、孜然味……最爱店家独创的秘制鸡翅。鸡翅的外皮被…

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

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

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…

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

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

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(读取评估打印循环)的浏览器&#…

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盏灯,你需要在每个房间里放入一盏灯。每盏灯都有一定功率,每间房间都需要不少于一定功率的灯泡才可以完全照亮。 你可以去附近的商店换新灯泡,商店里所有正整数功率的灯泡都有售。但由于背包空间有限,你…

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

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

因果推论第六章

因果推论 (Causal Inference) This is the sixth post on the series we work our way through “Causal Inference In Statistics” a nice Primer co-authored by Judea Pearl himself.这是本系列的第六篇文章,我们将通过Judea Pearl本人与他人合着的《引诱统计学…

如何优化网站加载时间

一、背景 我们要监测网站的加载情况,可以使用 window.performance 来简单的检测。 window.performance 是W3C性能小组引入的新的API,目前IE9以上的浏览器都支持。一个performance对象的完整结构如下图所示: memory字段代表JavaScript对内存的…

熊猫数据集_处理熊猫数据框中的列表值

熊猫数据集Have you ever dealt with a dataset that required you to work with list values? If so, you will understand how painful this can be. If you have not, you better prepare for it.您是否曾经处理过需要使用列表值的数据集? 如果是这样&#xff0…

旋转变换(一)旋转矩阵

1. 简介 计算机图形学中的应用非常广泛的变换是一种称为仿射变换的特殊变换,在仿射变换中的基本变换包括平移、旋转、缩放、剪切这几种。本文以及接下来的几篇文章重点介绍一下关于旋转的变换,包括二维旋转变换、三维旋转变换以及它的一些表达方式&#…

数据预处理 泰坦尼克号_了解泰坦尼克号数据集的数据预处理

数据预处理 泰坦尼克号什么是数据预处理? (What is Data Pre-Processing?) We know from my last blog that data preprocessing is a data mining technique that involves transforming raw data into an understandable format. Real-world data is often incom…

Pytorch中DNN入门思想及实现

DNN全连接层(线性层) 计算公式: y w * x b W和b是参与训练的参数 W的维度决定了隐含层输出的维度,一般称为隐单元个数(hidden size) b是偏差值(本文没考虑) 举例: 输…

IDEA去除mapper.xml文件中的sql语句的背景色

2019独角兽企业重金招聘Python工程师标准>>> IDEA版本 2017.3 mapper.xml文件中的sql语句,总是黄色一大片,看起来不舒服。 按如下设置进行设置即可 此时设置完还有点背景色 再进行一个设置 Ok,完美解决 转载于:https://my.oschina.net/u/3939…

vc6.0 绘制散点图_vc有关散点图的一切

vc6.0 绘制散点图Scatterplots are one of the most popular visualization techniques in the world. Its purposes are recognizing clusters and correlations in ‘pairs’ of variables. There are many variations of scatter plots. We will look at some of them.散点图…

Pytorch中RNN入门思想及实现

RNN循环神经网络 整体思想: 将整个序列划分成多个时间步,将每一个时间步的信息依次输入模型,同时将模型输出的结果传给下一个时间步,也就是说后面的结果受前面输入的影响。 RNN的实现公式: 个人思路: 首…

小扎不哭!FB又陷数据泄露风波,9000万用户受影响

对小扎来说,又是多灾多难的一个月。 继不久前Twitter曝出修补了一个可能造成数以百万计用户私密消息被共享给第三方开发人员的漏洞,连累Facebook股价跟着短线跳水之后,9月28日,Facebook又双叒叕曝出因安全漏洞遭到黑客攻击&#…

在衡量欧洲的政治意识形态时,调查规模的微小变化可能会很重要

(Related post: On a scale from 1 to 10, how much do the numbers used in survey scales really matter?)(相关文章: 从1到10的量表,调查量表中使用的数字到底有多重要? ) At Pew Research Center, survey questions about respondents’…