# practical-sql-2-main **Repository Path**: ground-gun/practical-sql-2-main ## Basic Information - **Project Name**: practical-sql-2-main - **Description**: practical-sql-2-书籍资料。来源practical-sql-2书籍源github仓库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-11 - **Last Updated**: 2025-10-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Practical SQL, 2nd Edition ### A Beginner's Guide to Storytelling with Data 用数据讲故事的初学者指南 [Practical SQL, 2nd Edition](https://nostarch.com/practical-sql-2nd-edition/) is a beginner-friendly guide to the database programming language SQL. Author [Anthony DeBarros](https://www.anthonydebarros.com) starts with beginner SQL concepts such as queries, data types, and basic math and aggregation, and then works through intermediate and advanced topics including statistics, cleaning data, GIS, and automating tasks. Along the way, you'll use real-world data from the U.S. Census and other government agencies and learn the fundamentals of good database design. This is a book not only about SQL but about best practices for using it for thorough, accurate data analysis. [实用SQL,第2版](https://nostarch.com/practical-sql-2nd-edition/)是数据库编程语言SQL的初学者友好指南。作者:安东尼·德巴罗斯(https://www.anthonydebarros.com)从初级SQL概念开始,如查询、数据类型、基本数学和聚合,然后学习中级和高级主题,包括统计、清理数据、GIS和自动化任务。在此过程中,您将使用来自美国人口普查局和其他政府机构的真实数据,并学习良好数据库设计的基础知识。这本书不仅是关于SQL的,也是关于使用它进行彻底、准确的数据分析的最佳实践的。 ## A Note About Editions 关于版本的说明 If you're reading the first edition of the book, published in 2018, please [use the code and data in the first edition repository](https://github.com/anthonydb/practical-sql/). If the cover of your copy does not say, "2nd Edition," then you're using the first edition. 如果您正在阅读2018年出版的这本书的第一版,请[使用第一版存储库中的代码和数据](https://github.com/anthonydb/practical-sql/).如果你的副本封面没有写“第二版”,那么你使用的是第一版。 ## Important Updates to pgAdmin pgAdmin的重要更新 In the book, we write SQL queries and manage our PostgreSQL databases with [pgAdmin](https://pgadmin.org), a free and open source graphical user interface. pgAdmin is under continuous development, and its current interface may differ from the screenshots and instructions in the book. Please check [the book FAQ](https://github.com/anthonydb/practical-sql-2/blob/master/faq-updates-errata.md) for updates. 在本书中,我们编写SQL查询并使用[pgAdmin]管理PostgreSQL数据库(https://pgadmin.org),一个免费开源的图形用户界面。pgAdmin正在不断开发中,其当前的界面可能与书中的截图和说明不同。请查看[本书常见问题](https://github.com/anthonydb/practical-sql-2/blob/master/faq-updates-errata.md)以获取更新。 ## Who Is This Book For? 这本书是给谁的? Practical SQL is ideal for beginners as well as those who know some SQL and want to go deeper. 实用的SQL非常适合初学者以及那些了解一些SQL并希望深入学习的人。 ## Which Database Does The Book Use? 这本书使用哪个数据库? We use [PostgreSQL](https://www.postgresql.org), which is free and open source. PostgreSQL is used by some of the world's largest companies. Its SQL syntax adheres closely to the ANSI SQL standard, and the concepts you learn will apply to most database management systems, including MySQL, Oracle, SQLite, and others. Note that Microsoft SQL Server employs a variant of SQL called T-SQL, which is not covered by Practical SQL. 我们使用[PostgreSQL](https://www.postgresql.org),它是免费和开源的。PostgreSQL被世界上一些最大的公司使用。它的SQL语法严格遵循ANSI SQL标准,你学到的概念将适用于大多数数据库管理系统,包括MySQL、Oracle、SQLite等。请注意,Microsoft SQL Server采用了一种名为T-SQL的SQL变体,而实用SQL并未涵盖此变体。 ## What's In This Repository? 这个存储库中有什么? **Code**: All the SQL statements and command-line listings used in each chapter, organized by chapter folders. **Data**: CSV and JSON files plus GIS shapefiles for you to import, also organized by chapter. **NOTE!** See the warning below about opening CSV files with Excel or text editors in the section on Getting the Code and Data. **Exercises**: The "Try It Yourself" questions and answers for each chapter, listed separately. Try working through the questions before peeking at the answers. **Software Installation Updates**: Over time, the instructions for installing PostgreSQL and additional components may change. You'll find updates noted at [software-installation-updates.md](https://github.com/anthonydb/practical-sql-2/blob/master/software-installation-updates.md). **FAQ, Updates, and Errata**: Answers to frequently asked questions, updates, and corrections are noted at [faq-updates-errata.md](https://github.com/anthonydb/practical-sql-2/blob/master/faq-updates-errata.md). **Resources**: Updates to the book's Appendix on Additional PostgreSQL Resources at [resources.md](https://github.com/anthonydb/practical-sql-2/blob/master/resources.md). **代码**:每章中使用的所有SQL语句和命令行列表,按章节文件夹组织。 **数据**:CSV和JSON文件以及GIS形状文件供您导入,也按章节组织。**注意!**请参阅“获取代码和数据”一节中关于使用Excel或文本编辑器打开CSV文件的警告。 **练习**:每章的“自己试试”问题和答案,分别列出。试着在看答案之前先把问题做完。 **软件安装更新**:随着时间的推移,PostgreSQL和其他组件的安装说明可能会发生变化。您可以在[软件安装更新.md]中找到更新(https://github.com/anthonydb/practical-sql-2/blob/master/software-installation-updates.md). **常见问题解答、更新和勘误表**:常见问题、更新和更正的答案请参见[FAQ-Updates-Errata.md](https://github.com/anthonydb/practical-sql-2/blob/master/faq-updates-errata.md). **资源**:本书附录关于PostgreSQL附加资源的更新,网址为[Resources.md](https://github.com/anthonydb/practical-sql-2/blob/master/resources.md). ## What's Covered in Each Chapter? * Chapter 1: Setting Up Your Coding Environment * Chapter 2: Creating Your First Database and Table * Chapter 3: Beginning Data Exploration with SELECT * Chapter 4: Understanding Data Types * Chapter 5: Importing and Exporting Data * Chapter 6: Basic Math and Stats with SQL * Chapter 7: Joining Tables in a Relational Database * Chapter 8: Table Design That Works for You * Chapter 9: Extracting Information by Grouping and Summarizing * Chapter 10: Inspecting and Modifying Data * Chapter 11: Statistical Functions In SQL * Chapter 12: Working With Dates and Times * Chapter 13: Advanced Query Techniques * Chapter 14: Mining Text to Find Meaningful Data * Chapter 15: Analyzing Spatial Data with PostGIS * Chapter 16: Working With JSON Data * Chapter 17: Saving Time with Views, Functions, and Triggers * Chapter 18: Using PostgreSQL from the Command Line * Chapter 19: Maintaining Your Database * Chapter 20: Telling Your Data's Story * Appendix: Additional PostgreSQL Resources ## How Do I Get the Code and Data? 如何获取代码和数据? **Non-GitHub Users** **非GitHub用户** You can obtain all the code and data at once by downloading this repository as a .zip file. To do that: 通过将此存储库下载为.zip文件,您可以一次获取所有代码和数据。要做到这一点: * Click the **Code** button at top right. * Click **Download ZIP** * Unzip the file on your computer. Place it in a directory that's easy to remember so you can reference it during the exercises that include importing data to PostgreSQL. * For additional instructions, please read Chapter 1 in the book. *点击右上角的**代码**按钮。 *点击**下载ZIP** *解压缩计算机上的文件。把它放在一个容易记住的目录中,这样你就可以在包括将数据导入PostgreSQL的练习中引用它。 *如需更多说明,请阅读本书第1章。 **Warning about CSV files!**: Opening CSV files with Excel could lead to data loss. Excel will remove leading zeros from numbers that are intended to be stored as text, such as ZIP codes. To view the contents of a CSV file, only do so with a plain-text editor and be careful not to save the file in an encoding other than UTF-8. **关于CSV文件的警告!**:使用Excel打开CSV文件可能会导致数据丢失。Excel将从要存储为文本的数字(如邮政编码)中删除前导零。要查看CSV文件的内容,请仅使用纯文本编辑器,并注意不要以UTF-8以外的编码保存文件。 **GitHub Users** GitHub users may want to clone the repository locally and occasionally perform a `git pull` to receive updates. **GitHub用户** GitHub用户可能希望在本地克隆存储库,并偶尔执行“git pull”以接收更新。 # Where Can I Buy the Book? 我在哪里可以买到这本书? Practical SQL, 2nd Edition is [available in PDF, .mobi, .epub, and classic print formats](https://nostarch.com/practical-sql-2nd-edition/). 实用SQL,第二版[有PDF、.mobi、.epub和经典打印格式](https://nostarch.com/practical-sql-2nd-edition/). # How Can I Get Help? 我如何获得帮助? Questions? Please open an issue in this repository by navigating to `Issues` and clicking `New Issue`. Fill out the form, and I will answer usually within 1 to 2 business days. For other types of inquiries, please email [practicalsqlbook@gmail.com](mailto:practicalsqlbook@gmail.com). 问题?请导航到“问题”并单击“新问题”,在此存储库中打开问题。填写表格,我通常会在1到2个工作日内回复。如需其他类型的咨询,请发送电子邮件至[practicalsqlbook@gmail.com](邮寄至:practicalsqlbook@gmail.com).