A Practical Guide to the Advanced Open Source Database
Regina O. Obe, Leo S. Hsu
SQL#
PostgreSQL#
psql#
data#
database#
آیا به مهاجرت به PostgreSQL فکر میکنید؟ این مقدمهی روشن و سریع به شما کمک میکند تا این سیستم پایگاهدادهی متنباز را درک کرده و از آن استفاده کنید. نهتنها با قابلیتهای سطح سازمانی در نسخههای 9.5 تا 10 آشنا میشوید، بلکه متوجه خواهید شد که PostgreSQL چیزی فراتر از یک پایگاهداده است — این یک پلتفرم قدرتمند برای توسعهی اپلیکیشن نیز هست.
این کتاب با مثالهایی در سراسر متن، روش انجام کارهایی را به شما نشان میدهد که در بسیاری از پایگاهدادههای دیگر دشوار یا حتی غیرممکن هستند. در ویرایش سوم، ویژگیهای جدیدی بررسی شدهاند، از جمله قابلیتهایی از استاندارد ANSI-SQL که تا پیش از این فقط در پایگاهدادههای انحصاری دیده میشدند: بهبودهای مربوط به foreign data wrapper (FDW)، توابع و عملگرهای جدید مربوط به جستجوی متن کامل در نسخهی 9.6، ساختارهای XML معرفیشده در نسخهی 10، قابلیت اجرای موازی کوئریها که در نسخهی 9.6 معرفی و در نسخهی 10 ارتقاء یافت، و تکثیر منطقی داخلی که از نسخهی 10 افزوده شده است.
اگر از کاربران فعلی PostgreSQL هستید، در این کتاب نکات کاربردی جدیدی خواهید یافت که شاید پیشتر از آنها بیخبر بودهاید.
در این کتاب یاد میگیرید:
psql
و رابط گرافیکی مدیریت pgAdmin
Thinking of migrating to PostgreSQL? This clear, fast-paced introduction helps you understand and use this open source database system. Not only will you learn about the enterprise class features in versions 9.5 to 10, you’ll also discover that PostgeSQL is more than a database system—it’s an impressive application platform as well.
With examples throughout, this book shows you how to achieve tasks that are difficult or impossible in other databases. This third edition covers new features, such as ANSI-SQL constructs found only in proprietary databases until now: foreign data wrapper (FDW) enhancements; new full text functions and operator syntax introduced in version 9.6; XML constructs new in version 10; query parallelization features introduced in 9.6 and enhanced in 10; built-in logical replication introduced in Version 10.e.
If you’re a current PostgreSQL user, you’ll pick up gems you may have missed before.
• Learn basic administration tasks such as role management, database creation, backup, and restore
• Apply the psql command-line utility and the pgAdmin graphical administration tool
• Explore PostgreSQL tables, constraints, and indexes
• Learn powerful SQL constructs not generally found in other databases
• Use several different languages to write database functions
• Tune your queries to run as fast as your hardware will allow
• Query external and variegated data sources with foreign data wrappers
• Learn how to use built-in replication to replicate data
From the Preface
PostgreSQL bills itself as the world’s most advanced open source database. We couldn’t agree more.
What we hope to accomplish in this book is to give you a firm grounding in the concepts and features that make PostgreSQL so impressive. Along the way, we should convince you that PostgreSQL does indeed stand up to its claim to fame. Because the database is advanced, no book short of the 3500 pages of documentation can bring out all its glory. But then again, most users don’t need to delve into the most abstruse features that PostgreSQL has to offer. So in our shorter 300-pager, we hope to get you, as the subtitle proclaims, Up and Running.
Each topic is presented with some context so you understand when to use it and what it offers. We assume you have prior experience with some other database so that we can jump right to the key points of PostgreSQL. We generously litter the pages of this book with links to references so you can dig deeper into topics of interest. These links lead to sections in the manual, to helpful articles, to blog posts of PostgreSQL vanguards. We also link to our own site at Postgres OnLine Journal, where we have collected many pieces that we have written on PostgreSQL and its interoperability with other applications.
This book focuses on PostgreSQL versions 9.5, 9.6, and 10, but we will cover some unique and advanced features that are also present in prior versions.
For migrants from other database engines, we’ll point out parallels that PostgreSQL shares with other leading products. Perhaps more importantly, we highlight feats you can achieve with PostgreSQL that are difficult or impossible to do in other databases.
We stop short of teaching you SQL, as you’ll find many excellent sources for that. SQL is much like chess—a few hours to learn, a lifetime to master. You have wisely chosen PostgreSQL. You’ll be greatly rewarded.
If you’re currently a savvy PostgreSQL user or a weather-beaten DBA, much of the material in this book should be familiar terrain, but you’ll be sure to pick up some pointers and shortcuts introduced in newer versions of PostgreSQL. Perhaps you’ll even find the hidden gem that eluded you. If nothing else, this book is at least ten times lighter than the PostgreSQL manual.
Not using PostgreSQL yet? This book is propaganda—the good kind. Each day you continue to use a database with limited SQL capabilities, you handicap yourself. Each day that you’re wedded to a proprietary system, you’re bleeding dollars.
Finally, if your work has nothing to do with databases or IT, or if you’ve just graduated from kindergarten, the cute picture of the elephant shrew on the cover should be worthy of the price alone.
Table of Contents
Chapter 1. The Basics
Chapter 2. Database Administration
Chapter 3. psql
Chapter 4. Using pgAdmin
Chapter 5. Data Types
Chapter 6. Tables, Constraints, and Indexes
Chapter 7. SQL: The PostgreSQL Way
Chapter 8. Writing Functions
Chapter 9. Query Performance Tuning
Chapter 10. Replication and External Data
Appendix A. Installing PostgreSQL
Appendix B. PostgreSQL Packaged Command-Line Tools
About the Author
Regina Obe is a co-principal of Paragon Corporation, a database consulting company based in Boston. She has over 15 years of professional experience in various programming languages and database systems, with special focus on spatial databases. She is a member of the PostGIS steering committee and the PostGIS core development team. Regina holds a BS degree in mechanical engineering from the Massachusetts Institute of Technology. She co-authored PostGIS in Action.
Leo Hsu is a co-principal of Paragon Corporation, a database consulting company based in Boston. He has over 15 years of professional experience developing and thinking about databases for organizations large and small. Leo holds an MS degree in engineering of economic systems from Stanford University and BS degrees in mechanical engineering and economics from the Massachusetts Institute of Technology. He co-authored PostGIS in Action.