數據庫邏輯刪除的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.pswp.cn/news/389617.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/389617.shtml
英文地址,請注明出處:http://en.pswp.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…