Part II. The SQL Language
This part describes the use of the SQL language in PostgreSQL. We start with describing the general syntax of SQL, then how to create tables, how to populate the database, and how to query it. The middle part lists the available data types and functions for use in SQL commands. Lastly, we address several aspects of importance for tuning a database.
The information is arranged so that a novice user can follow it from start to end and gain a full understanding of the topics without having to refer forward too many times. The chapters are intended to be self-contained, so that advanced users can read the chapters individually as they choose. The information is presented in narrative form with topical units. Readers looking for a complete description of a particular command are encouraged to review the Part VI.
Readers should know how to connect to a PostgreSQL database and issue SQL commands. Readers that are unfamiliar with these issues are encouraged to read Part I first. SQL commands are typically entered using the PostgreSQL interactive terminal psql, but other programs that have similar functionality can be used as well.
Table of Contents
- 4. SQL Syntax
- 5. Data Definition
- 5.1. Table Basics
- 5.2. Default Values
- 5.3. Identity Columns
- 5.4. Generated Columns
- 5.5. Constraints
- 5.6. System Columns
- 5.7. Modifying Tables
- 5.8. Privileges
- 5.9. Row Security Policies
- 5.10. Schemas
- 5.11. Inheritance
- 5.12. Table Partitioning
- 5.13. Foreign Data
- 5.14. Other Database Objects
- 5.15. Dependency Tracking
- 5.2. Default Values
- 5.1. Table Basics
- 6. Data Manipulation
- 7. Queries
- 8. Data Types
- 8.1. Numeric Types
- 8.2. Monetary Types
- 8.3. Character Types
- 8.4. Binary Data Types
- 8.5. Date/Time Types
- 8.6. Boolean Type
- 8.7. Enumerated Types
- 8.8. Geometric Types
- 8.9. Network Address Types
- 8.10. Bit String Types
- 8.11. Text Search Types
- 8.12. UUID Type
- 8.13. XML Type
- 8.14. JSON Types
- 8.15. Arrays
- 8.16. Composite Types
- 8.17. Range Types
- 8.18. Domain Types
- 8.19. Object Identifier Types
- 8.20.
pg_lsn
Type- 8.21. Pseudo-Types
- 8.2. Monetary Types
- 8.1. Numeric Types
- 9. Functions and Operators
- 9.1. Logical Operators
- 9.2. Comparison Functions and Operators
- 9.3. Mathematical Functions and Operators
- 9.4. String Functions and Operators
- 9.5. Binary String Functions and Operators
- 9.6. Bit String Functions and Operators
- 9.7. Pattern Matching
- 9.8. Data Type Formatting Functions
- 9.9. Date/Time Functions and Operators
- 9.10. Enum Support Functions
- 9.11. Geometric Functions and Operators
- 9.12. Network Address Functions and Operators
- 9.13. Text Search Functions and Operators
- 9.14. UUID Functions
- 9.15. XML Functions
- 9.16. JSON Functions and Operators
- 9.17. Sequence Manipulation Functions
- 9.18. Conditional Expressions
- 9.19. Array Functions and Operators
- 9.20. Range/Multirange Functions and Operators
- 9.21. Aggregate Functions
- 9.22. Window Functions
- 9.23. Merge Support Functions
- 9.24. Subquery Expressions
- 9.25. Row and Array Comparisons
- 9.26. Set Returning Functions
- 9.27. System Information Functions and Operators
- 9.28. System Administration Functions
- 9.29. Trigger Functions
- 9.30. Event Trigger Functions
- 9.31. Statistics Information Functions
- 9.2. Comparison Functions and Operators
- 9.1. Logical Operators
- 10. Type Conversion
- 11. Indexes
- 11.1. Introduction
- 11.2. Index Types
- 11.3. Multicolumn Indexes
- 11.4. Indexes and
ORDER BY
- 11.5. Combining Multiple Indexes
- 11.6. Unique Indexes
- 11.7. Indexes on Expressions
- 11.8. Partial Indexes
- 11.9. Index-Only Scans and Covering Indexes
- 11.10. Operator Classes and Operator Families
- 11.11. Indexes and Collations
- 11.12. Examining Index Usage
- 11.2. Index Types
- 11.1. Introduction
- 12. Full Text Search
- 13. Concurrency Control
- 14. Performance Tips
- 15. Parallel Query