學習sql注入:猜測數據庫_面向數據科學家SQL:學習簡單方法

學習sql注入:猜測數據庫

We don’t pick a hammer and look for nails — that would be an unusual way of solving problems. The usual way of doing business is to identify the problem first, then look for appropriate tools.

我們不用錘子找釘子,那是解決問題的不尋常方式。 做生意的通常方法是先確定問題,然后尋找合適的工具。

I’ve seen over and over again people learn SQL by picking a SQL statement and then learn how to use it. In my opinion, this tool-based mindset is an inefficient way of learning things, and on the other hand, flipping this mindset can make a huge difference. Problems first, tools to follow!

我已經一遍又一遍地看到人們通過選擇一條SQL語句來學習SQL,然后學習如何使用它。 我認為,這種基于工具的思維方式是一種學習事物的低效方式,另一方面,翻轉這種思維方式可能會產生巨大的變化。 問題第一,工具跟隨!

If you are into data science, you know the capabilities of pandas andtidyversetin filtering, sorting, grouping, merging — all sorts of data handling operations. With SQL you will do similar things, but in a database environment and using a different language.

如果您對數據科學tidyverset ,那么您將了解pandastidyverset在過濾,排序,分組和合并(各種數據處理操作)中的功能。 使用SQL,您將執行類似的操作,但是要在數據庫環境中并使用另一種語言。

The purpose of this article is to demonstrate how to solve data handling problems in SQL taking a similar approach that data scientists typically follow in a programming environment. You will not learn everything under the sun on SQL, rather the objective is to show “how to” learn.

本文的目的是演示如何使用數據科學家通常在編程環境中遵循的類似方法來解決SQL中的數據處理問題。 您不會在SQL的基礎上學到所有東西,而是要展示“如何”學習。

適用于您的實踐SQL編輯器 (SQL editor for your practice)

If you have a relational database management system installed on your computer, fire it up. If not, w3schools has an online SQL editor that you can use right away on your browser.

如果您的計算機上安裝了關系數據庫管理系統,請啟動它。 如果沒有,則w3schools有一個在線SQL編輯器,您可以在瀏覽器上立即使用它。

You’ll also notice there are quite a few datasets on the right side of the screen that you can use and practice along.

您還將注意到屏幕右側有很多數據集,您可以使用和實踐。

Now let’s get into “how to” solve actual data handling problems using SQL.

現在讓我們進入“如何”使用SQL解決實際數據處理問題的過程。

了解數據 (Understanding data)

Just like what you do with your favorite programming library such aspandas, the first thing you need to do is loading the dataset in the SQL environment.

就像您對喜歡的編程庫(如pandas所做的一樣,您需要做的第一件事是在SQL環境中加載數據集。

And like basic exploratory data analysis (EDA) in a typical data science project, you are able to check out the first few rows, count the total number of rows, see column names, data types etc. Below are a few commands.

與典型數據科學項目中的基本探索性數據分析(EDA)一樣,您可以簽出前幾行,計算行的總數,查看列名,數據類型等。以下是一些命令。

# import data into editor
SELECT * # import all columns with *, else specify column name
FROM table_name
LIMIT 10 #to show 10 rows# import and save data as a separate table
SELECT *
INTO new_table_name
FROM table_name# count number of rows in the dataset
SELECT
COUNT(*)
FROM table_name# count unique values of a single column
SELECT
COUNT(DISTINCT column_name)
FROM table_name

使用列 (Working with columns)

Databases are often quite large, it can take a long time to run queries. So if you know what specific columns you are interested in, you could just make a subset of the data by selecting those columns.

數據庫通常很大,運行查詢可能需要很長時間。 因此,如果您知道感興趣的特定列,則可以通過選擇這些列來構成數據的子集。

You might also want to perform column operations such as renaming, creating new columns etc.

您可能還需要執行列操作,例如重命名,創建新列等。

# select two columns from a multi-column dataset
SELECT column1, column2
FROM tableName# rename a column
SELECT
ProductName AS name
FROM productTable# new conditional column (similar to if statment)
SELECT ProductName, Price,(CASE
WHEN Price > 20 AND Price <41 THEN 'medium '
WHEN Price >40 THEN 'high'
ELSE 'low'
END) AS newColNameFROM Products

篩選行 (Filtering rows)

Filtering rows is probably the most important task you will do frequently with SQL. From a large dataset you’ll often filter rows based on product type, range of values etc.

過濾行可能是您將經常使用SQL進行的最重要的任務。 在大型數據集中,您經常會根據產品類型,值范圍等來過濾行。

If you are learning SQL you should devote a substantial amount of time learning the many different ways to filter data and the SQL statements you’ll need.

如果您正在學習SQL,則應該花大量時間學習各種不同的過濾數據和所需SQL語句的方法。

# select all records that starts with the letter "S"
SELECT * FROM Products
WHERE ProductName like 'S%'# select all records that end at "S"
SELECT * FROM Products
WHERE ProductName like '%S'# select all records that does NOT start at "S"
SELECT * FROM Products
WHERE ProductName like '[^S]%'# filter rows with specific value
SELECT * FROM table_nameWHERE firstName = 'Pilu'
OR lastName != 'Milu'
AND income <= 100
AND city IN ('Arlington', 'Burlington', 'Fairfax')# filter rows within a range of numbers
SELECT *
FROM tableName
WHERE income BETWEEN 100 AND 200 # filter null values
SELECT * FROM tableName
WHERE columnName IS NULL # opposite "IS NOT NULL"

聯接數據集 (Joining datasets)

You are using SQL in a relational database management system (RDBMS), which means you will be working with multiple tables at a time, so they need to be joined before you are able to do advanced modeling.

您正在關系數據庫管理系統(RDBMS)中使用SQL,這意味著您將一次處理多個表,因此在進行高級建模之前需要將它們連接在一起。

There are basically four ways to join data — left, right, inner, full outer joins — and you need to google a little bit to see how each works, but I’m giving all the codes below to perform these joins.

基本上有四種連接數據的方法-左,右,內部,完全外部聯接-您需要用一點點Google來了解每種方法的工作原理,但是我在下面提供了所有代碼來執行這些聯接。

# inner join (for matching records only)
SELECT * FROM
table1 INNER JOIN table2
ON table1.ID = tbale2.ID# full outer join (all left + all right)
SELECT * FROM
table1 FULL OUTER JOIN table2
ON table1.ID = tbale2.ID# left join (all records from left + matching records from right)
SELECT * FROM
table1 LEFT JOIN table2
ON table1.ID = tbale2.ID# left join (matching records from left + all records from right)
SELECT * FROM
table1 RIGHT JOIN table2
ON table1.ID = tbale2.ID

進行計算 (Doing calculations)

Creating summary statistics, mathematical operations and building models is what you do every day as a data scientist. SQL is not the right tool for much of that, however, if you need to create a quick summary statistics you can use aggregate functions to calculate column mean, totals, min/max values etc.

創建匯總統計信息,數學運算和構建模型是您作為數據科學家每天要做的事情。 SQL并不是大多數情況下的正確工具,但是,如果您需要創建快速匯總統計信息,則可以使用聚合函數來計算列平均值,總計,最小/最大值等。

# new calculated column
SELECT Price,
(Price * 2) AS NewCol
FROM Products# aggregation by group
SELECT CategoryID, SUM(Price)
FROM Products
GROUP BY CategoryID# min/max values of a column
SELECT ProductName, MIN(Price)
FROM Products

最后的筆記 (Final notes)

The purpose of this article was to introduce some basic SQL concepts and statements for querying data from a relational database management system. But the primary objective was to show how to learn SQL as a data scientist with a mindset to solve a particular problem rather than focusing on SQL statements.

本文的目的是介紹一些基本SQL概念和語句,用于從關系數據庫管理系統中查詢數據。 但是主要目的是展示如何以解決特定問題的思維方式來學習數據科學家,而不是專注于SQL語句。

翻譯自: https://towardsdatascience.com/sql-for-data-scientists-learning-it-easy-way-798122c6d4e6

學習sql注入:猜測數據庫

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/392082.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392082.shtml
英文地址,請注明出處:http://en.pswp.cn/news/392082.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

android 百度地圖3.0,android 百度地圖3.0

一&#xff1a;為地圖設置事件注意新版本中要有一個getMapmMapView.getMap().setOnMapStatusChangeListener(listener);OnMapStatusChangeListener listener newOnMapStatusChangeListener() {/*** 手勢操作地圖&#xff0c;設置地圖狀態等操作導致地圖狀態開始改變。* param s…

(摘錄)sockaddr與sockaddr_in,sockaddr_un結構體詳細講解

struct sockaddr { unsigned short sa_family; /* address family, AF_xxx */ char sa_data[14]; /* 14 bytes of protocol address */ }; sa_family是地址家族&#xff0c;一般都是“AF_xxx”的形式。好像通常大多用的是都是AF_INET。 sa_data是14字節協議…

數據挖掘—K-中心點聚類算法(Java實現)

K-中心點聚類算法 &#xff08;1&#xff09;任意選擇k個對象作為初始的簇中心點 &#xff08;2&#xff09;指派每個剩余對象給離他最近的中心點所表示的簇 &#xff08;3&#xff09;選擇一個未被選擇的中心點直到所有的中心點都被選擇過 &#xff08;4&#xff09;選擇一個…

使用akka構建高并發程序_如何使用Akka Cluster創建簡單的應用程序

使用akka構建高并發程序If you read my previous story about Scalachain, you probably noticed that it is far from being a distributed system. It lacks all the features to properly work with other nodes. Add to it that a blockchain composed by a single node is…

pandas之數值計算與統計

數值計算與統計 對于DataFrame來說&#xff0c;求和、最大、最小、平均等統計方法&#xff0c;默認是按列進行統計&#xff0c;即axis 0&#xff0c;如果添加參數axis 1則會按照行進行統計。 如果存在空值&#xff0c;在統計時默認會忽略空值&#xff0c;如果添加參數skipna …

python自動化數據報告_如何:使用Python將實時數據自動化到您的網站

python自動化數據報告This tutorial will be helpful for people who have a website that hosts live data on a cloud service but are unsure how to completely automate the updating of the live data so the website becomes hassle free. For example: I host a websit…

一顆站在技術邊緣的土豆

2012年開始上專業課&#xff0c;2013年打了一年游戲&#xff0c;年底專業課忘光了&#xff0c;但是蒙混過關沒掛科&#xff0c;2014年7月份畢業&#xff0c;對這個社會充滿向往。2014年9月份——方正代理商做網絡安全公司。2015年3月份跳槽到一家vmware代理商公司。2016年6月&a…

leetcode 839. 相似字符串組(并查集)

如果交換字符串 X 中的兩個不同位置的字母&#xff0c;使得它和字符串 Y 相等&#xff0c;那么稱 X 和 Y 兩個字符串相似。如果這兩個字符串本身是相等的&#xff0c;那它們也是相似的。 例如&#xff0c;“tars” 和 “rats” 是相似的 (交換 0 與 2 的位置)&#xff1b; “r…

android intent參數是上次的結果,【Android】7.0 Intent向下一個活動傳遞數據、返回數據給上一個活動...

1.0 可以利用Intent吧數據傳遞給上一個活動&#xff0c;新建一個叫“hellotest01”的項目。新建活動FirstActivity&#xff0c;勾選“Generate Layout File”和“Launcher Activity”。image修改AndroidMainifest.xml中的內容&#xff1a;android:name".FirstActivity&quo…

實習一年算工作一年嗎?_經過一年的努力,我如何找到軟件工程工作

實習一年算工作一年嗎?by Andrew Ngo通過安德魯恩戈 經過一年的努力&#xff0c;我如何找到軟件工程工作 (How I landed a software engineering job after a year of hard work) Many of us think the path to becoming a software engineer requires years of education an…

學習深度學習需要哪些知識_您想了解的有關深度學習的所有知識

學習深度學習需要哪些知識有關深層學習的FAU講義 (FAU LECTURE NOTES ON DEEP LEARNING) Corona was a huge challenge for many of us and affected our lives in a variety of ways. I have been teaching a class on Deep Learning at Friedrich-Alexander-University Erlan…

參加開發競賽遇到的問題【總結】

等比賽完就寫。 轉載于:https://www.cnblogs.com/jiangyuanjia/p/11261978.html

html5--3.16 button元素

html5--3.16 button元素 學習要點 掌握button元素的使用button元素 用來建立一個按鈕從功能上來說&#xff0c;與input元素建立的按鈕相同button元素是雙標簽&#xff0c;其內部可以配置圖片與文字&#xff0c;進行更復雜的樣式設計不僅可以在表單中使用&#xff0c;還可以在其…

如何注冊鴻蒙id,鴻蒙系統真機調試證書 和 設備ID獲取

鴻蒙系統真機調試創建項目創建項目創建應用創建鴻蒙應用(注意&#xff0c;測試階段需要發郵件申請即可)關聯應用項目進入關聯 添加引用準備調試使用的 p12 和證書請求 csr使用以下命令// 別名"test"可以修改&#xff0c;但必須前后一致&#xff0c;密碼請自行修改key…

Java—實現 IOC 功能的簡單 Spring 框架

編寫一個實現 IOC 功能的簡單 Spring 框架&#xff0c;包含對象注冊、對象管理、及暴 露給外部獲取對象的功能&#xff0c;并編寫測試程序。擴展注冊器的方式&#xff0c;要求采用 XML 和 txt 文件。 源代碼 package myspring;import java.lang.reflect.Method; import java.…

讀zepto核心源碼學習JS筆記(3)--zepto.init()

上篇已經講解了zepto.init()的幾種情況,這篇就繼續記錄這幾種情況下的具體分析. 1. 首先是第一種情況,selector為空 既然是反向分析,那我們先看看這句話的代碼; if (!selector) return zepto.Z() 這里的返回值為zepto.Z();那我們繼續往上找zepto.Z()函數 zepto.Z function(dom…

css flexbox模型_Flexbox和CSS Grid之間的主要區別

css flexbox模型by Shaira Williams由莎拉威廉姆斯(Shaira Williams) Flexbox和CSS Grid之間的主要區別 (The main differences between Flexbox and CSS Grid) Dimensions define the primary demarcation between Flexbox and CSS Grid. Flexbox was designed specifically …

置信區間估計 預測區間估計_估計,預測和預測

置信區間估計 預測區間估計Estimation implies finding the optimal parameter using historical data whereas prediction uses the data to compute the random value of the unseen data.估計意味著使用歷史數據找到最佳參數&#xff0c;而預測則使用該數據來計算未見數據的…

鴻蒙系統還會推出嗎,華為明年所有自研設備都升級鴻蒙系統,還會推出基于鴻蒙系統的新機...

不負期許&#xff0c;華為鴻蒙OS手機版如期而至。今日(12月15日)&#xff0c;鴻蒙OS 2.0手機開發者Beta版本正式上線&#xff0c;支持運行安卓應用&#xff0c;P40、Mate 30系列可申請公測。國內媒體報道稱&#xff0c;華為消費者業務軟件部副總裁楊海松表示&#xff0c;按照目…

C#中將DLL文件打包到EXE文件

1&#xff1a;在工程目錄增加dll目錄&#xff0c;然后將dll文件復制到此目錄&#xff0c;例如&#xff1a; 2&#xff1a;增加引用&#xff0c;定位到工程的dll目錄&#xff0c;選中要增加的dll文件 3&#xff1a;修改dll文件夾下面的dll文件屬性 選中嵌入式資源&#xff0c;不…