学习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.mzph.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;不…