学习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 editorSELECT * # import all columns with *, else specify column nameFROM table_nameLIMIT 10 #to show 10 rows# import and save data as a separate tableSELECT *INTO new_table_nameFROM table_name# count number of rows in the datasetSELECT COUNT(*)FROM table_name# count unique values of a single columnSELECT 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 datasetSELECT column1, column2FROM tableName# rename a columnSELECTProductName AS nameFROM productTable# new conditional column (similar to if statment)SELECT ProductName, Price,(CASEWHEN 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 ProductsWHERE ProductName like 'S%'# select all records that end at "S"SELECT * FROM ProductsWHERE ProductName like '%S'# select all records that does NOT start at "S"SELECT * FROM ProductsWHERE ProductName like '[^S]%'# filter rows with specific valueSELECT * FROM table_nameWHERE firstName = 'Pilu'OR lastName != 'Milu'AND income <= 100AND city IN ('Arlington', 'Burlington', 'Fairfax')# filter rows within a range of numbersSELECT *FROM tableNameWHERE income BETWEEN 100 AND 200 # filter null valuesSELECT * FROM tableNameWHERE 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 * FROMtable1 INNER JOIN table2ON table1.ID = tbale2.ID# full outer join (all left + all right)SELECT * FROMtable1 FULL OUTER JOIN table2ON table1.ID = tbale2.ID# left join (all records from left + matching records from right)SELECT * FROMtable1 LEFT JOIN table2ON table1.ID = tbale2.ID# left join (matching records from left + all records from right)SELECT * FROMtable1 RIGHT JOIN table2ON 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 columnSELECT Price,(Price * 2) AS NewColFROM Products# aggregation by groupSELECT CategoryID, SUM(Price) FROM ProductsGROUP BY CategoryID# min/max values of a columnSELECT 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.taodudu.cc/news/show-997572.html

相关文章:

  • python自动化数据报告_如何:使用Python将实时数据自动化到您的网站
  • 学习深度学习需要哪些知识_您想了解的有关深度学习的所有知识
  • 置信区间估计 预测区间估计_估计,预测和预测
  • 地图 c-suite_C-Suite的模型
  • sap中泰国有预扣税设置吗_泰国餐厅密度细分:带有K-means聚类的python
  • 傅里叶变换 直观_A / B测试的直观模拟
  • 鸽子 迷信_人工智能如何帮助我战胜鸽子
  • scikit keras_Scikit学习,TensorFlow,PyTorch,Keras…但是天秤座呢?
  • 数据结构两个月学完_这是我作为数据科学家两年来所学到的
  • 迈向数据科学的第一步:在Python中支持向量回归
  • 使用Python和MetaTrader在5分钟内开始构建您的交易策略
  • ipywidgets_未来价值和Ipywidgets
  • 用folium模块画地理图_使用Folium表示您的地理空间数据
  • python创建类统计属性_轻松创建统计数据的Python包
  • knn分类 knn_关于KNN的快速小课程
  • 机器学习集群_机器学习中的多合一集群技术在无监督学习中应该了解
  • 政府公开数据可视化_公开演讲如何帮助您设计更好的数据可视化
  • 消费者行为分析_消费者行为分析-是否点击广告?
  • 魅族mx5游戏模式小熊猫_您不知道的5大熊猫技巧
  • 数据科学中的数据可视化
  • 多重线性回归 多元线性回归_了解多元线性回归
  • 如何使用Python处理丢失的数据
  • 为什么印度盛产码农_印度农产品价格的时间序列分析
  • tukey检测_回到数据分析的未来:Tukey真空度的整洁实现
  • 到2025年将保持不变的热门流行技术
  • 马尔科夫链蒙特卡洛_蒙特卡洛·马可夫链
  • 数据分布策略_有效数据项目的三种策略
  • 密度聚类dbscan_DBSCAN —基于密度的聚类方法的演练
  • 从完整的新手到通过TensorFlow开发人员证书考试
  • 移动平均线ma分析_使用动态移动平均线构建交互式库存量和价格分析图

学习sql注入:猜测数据库_面向数据科学家SQL:学习简单方法相关推荐

  1. 学习sql注入:猜测数据库_学习SQL:删除和更新数据SQL最佳实践

    学习sql注入:猜测数据库 Deleting and updating data is very common, but if performed without taking care, which ...

  2. 学习sql注入:猜测数据库_对于SQL的热爱:为什么要学习它以及它将如何帮助您...

    学习sql注入:猜测数据库 I recently read a great article by the esteemed @craigkerstiens describing why he feel ...

  3. 学习sql注入:猜测数据库_学习SQL:SQL数据类型

    学习sql注入:猜测数据库 What are SQL data types, why do we need them, and how to use them? Today, we'll try to ...

  4. sql重命名数据库_为什么要为SQL单元测试巧妙地命名数据库对象

    sql重命名数据库 This article is focussed on clever database object naming from both development and SQL un ...

  5. 面向数据编程的编程语言_面向数据科学家的10个很棒的编程项目

    面向数据编程的编程语言 Practice is an essential part of learning. But in my experience learning programming, fi ...

  6. sql备份恢复数据库_使用DBATools通过SQL恢复数据库操作验证备份

    sql备份恢复数据库 In this article, we will explore database backup validation by with SQL restore database ...

  7. spark sql读取hive底层_[大数据]spark sql读写Hive数据不一致

    在大数据公司中,任何一家公司都不会只使用一个框架吧?! skr,skr~~ 那我们今天就来聊一段 Hive 与 Spark的爱恨情仇 就像 在一些场景中,需要将外部的数据导入到Hive表中,然后再对这 ...

  8. 海量数据寻找最频繁的数据_寻找数据科学家的“原因”

    海量数据寻找最频繁的数据 Start with "Why" - Why do we do the work we do? 从"为什么"开始-我们为什么要做我们所 ...

  9. mysql sql注入怎么获取数据_手把手教你通过SQL注入盗取数据库信息

    目录数据库结构 注入示例判断共有多少字段 判断字段的显示位置 显示登录用户和数据库名 获取所有数据库名 获取对应数据库的表 获取对应表的字段 获取所有的用户密码 我们都是善良的银!一生戎码只为行侠仗义 ...

最新文章

  1. gitosis使用笔记
  2. ubuntu python3.5升级3.6_ubuntu16.04升级Python3.5到Python3.7
  3. Python爬虫开发:fake_useragent库伪造User-Agent
  4. 手工计算YARN和MapReduce、tez内存配置设置
  5. Real to Int
  6. 前端学习(3192):react第一个案例
  7. 前端学习(1308):URl
  8. 22.敏捷估计与规划——Why Agile Planning Works笔记
  9. 只想问你一句:“伤害我,你会心疼吗?”
  10. 记杨绛先生的经典语句
  11. centos安装python3小白_centos7安装python3
  12. domain name
  13. win7 简体中文旗舰版 MSDN官方原版
  14. ffmpeg 图像格式转换
  15. RSE2021/云检测:Automatic cloud and cloud shadow detection in tropical areas用于PlanetScope热带地区自动云和云阴影检测
  16. word2016加载MathType打开时显示“安全警告,宏已被禁用”解决办法
  17. win2003服务器端口修改,Windows 2003修改3389端口的方法
  18. Elk和splunk的区别调研报告
  19. 云计算机概念,云计算是什么意思?
  20. Window对象的说明》

热门文章

  1. 【转载】移动端布局概念总结
  2. C# 实现一个可取消的多线程操作 示例
  3. JavaScript DOM编程艺术第二版学习(1/4)
  4. iOS开发学无止境 - NSFileManager文件操作的十个小功能
  5. 定义jQuery插件
  6. jenkins的JAVA简单顺序配置git仓库
  7. Android7.0反射类找不到的问题
  8. python-windows安装相关问题
  9. PostCSS 以及 cssnext语法
  10. 认证鉴权与API权限控制在微服务架构中的设计与实现(一)