# 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 explain how to create the structures to hold data, 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. The rest treats several aspects that are important for tuning a database for optimal performance. The information in this part is arranged so that a novice user can follow it start to end to 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 in this part is presented in a narrative fashion in topical units. Readers looking for a complete description of a particular command should see[Part VI](reference.html). Readers of this part 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](tutorial.html)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](sql-syntax.html) [4.1. Lexical Structure](sql-syntax-lexical.html) [4.2. Value Expressions](sql-expressions.html) [4.3. Calling Functions](sql-syntax-calling-funcs.html) [5. Data Definition](ddl.html) [5.1. Table Basics](ddl-basics.html) [5.2. Default Values](ddl-default.html) [5.3. Generated Columns](ddl-generated-columns.html) [5.4. Constraints](ddl-constraints.html) [5.5. System Columns](ddl-system-columns.html) [5.6. Modifying Tables](ddl-alter.html) [5.7. Privileges](ddl-priv.html) [5.8. Row Security Policies](ddl-rowsecurity.html) [5.9. Schemas](ddl-schemas.html) [5.10. Inheritance](ddl-inherit.html) [5.11. Table Partitioning](ddl-partitioning.html) [5.12. Foreign Data](ddl-foreign-data.html) [5.13. Other Database Objects](ddl-others.html) [5.14. Dependency Tracking](ddl-depend.html) [6. Data Manipulation](dml.html) [6.1. Inserting Data](dml-insert.html) [6.2. Updating Data](dml-update.html) [6.3. Deleting Data](dml-delete.html) [6.4. Returning Data from Modified Rows](dml-returning.html) [7. Queries](queries.html) [7.1. Overview](queries-overview.html) [7.2. Table Expressions](queries-table-expressions.html) [7.3. Select Lists](queries-select-lists.html) [7.4. Combining Queries (`UNION`,`INTERSECT`,`EXCEPT`)](queries-union.html) [7.5. Sorting Rows (`ORDER BY`)](queries-order.html) [7.6.`LIMIT`and`OFFSET`](queries-limit.html) [7.7.`VALUES`Lists](queries-values.html) [7.8.`WITH`Queries (Common Table Expressions)](queries-with.html) [8. Data Types](datatype.html) [8.1。数值类型](datatype-numeric.html) [8.2.货币类型](datatype-money.html) [8.3.字符类型](datatype-character.html) [8.4.二进制数据类型](datatype-binary.html) [8.5。日期/时间类型](datatype-datetime.html) [8.6.布尔类型](datatype-boolean.html) [8.7.枚举类型](datatype-enum.html) [8.8.几何类型](datatype-geometric.html) [8.9。网络地址类型](datatype-net-types.html) [8.10。位串类型](datatype-bit.html) [8.11。文本搜索类型](datatype-textsearch.html) [8.12。UUID 类型](datatype-uuid.html) [8.13。XML 类型](datatype-xml.html) [8.14。JSON 类型](datatype-json.html) [8.15。数组](arrays.html) [8.16。复合类型](rowtypes.html) [8.17。范围类型](rangetypes.html) [8.18。域类型](domains.html) [8.19。对象标识符类型](datatype-oid.html) [8.20。`pg_lsn`类型](datatype-pg-lsn.html) [8.21。伪类型](datatype-pseudo.html) [9. 函数和运算符9.1。](functions.html) [逻辑运算符9.2.](functions-logical.html) [比较函数和运算符9.3.](functions-comparison.html) [数学函数和运算符9.4。](functions-math.html) [字符串函数和运算符9.5。](functions-string.html) [二进制字符串函数和运算符](functions-binarystring.html) [9.6。位串函数和运算符](functions-bitstring.html) [9.7。模式匹配](functions-matching.html) [9.8。数据类型格式化函数](functions-formatting.html) [9.9。日期/时间函数和运算符](functions-datetime.html) [9.10。枚举支持函数](functions-enum.html) [9.11。几何函数和运算符](functions-geometry.html) [9.12。网络地址函数和运算符](functions-net.html) [9.13。文本搜索函数和运算符](functions-textsearch.html) [9.14。UUID 函数](functions-uuid.html) [9.15。XML 函数](functions-xml.html) [9.16。JSON 函数和运算符](functions-json.html) [9.17。序列操作函数](functions-sequence.html) [9.18。条件表达式](functions-conditional.html) [9.19。数组函数和运算符](functions-array.html) [9.20。范围/多范围函数和运算符](functions-range.html) [9.21。聚合函数](functions-aggregate.html) [9.22。窗口函数](functions-window.html) [9.23。子查询表达式](functions-subquery.html) [9.24。行和数组比较](functions-comparisons.html) [9.25。设置返回函数](functions-srf.html) [9.26。系统信息函数和运算符](functions-info.html) [9.27。系统管理功能](functions-admin.html) [9.28。触发函数](functions-trigger.html) [9.29。事件触发函数](functions-event-triggers.html) [9.30。统计信息功能](functions-statistics.html) [10. 类型转换10.1。](typeconv.html) [概述10.2.](typeconv-overview.html) [运营商10.3.](typeconv-oper.html) [职能](typeconv-func.html) [10.4. Value Storage](typeconv-query.html) [10.5.`UNION`,`CASE`, and Related Constructs](typeconv-union-case.html) [10.6.`SELECT`Output Columns](typeconv-select.html) [11. Indexes](indexes.html) [11.1. Introduction](indexes-intro.html) [11.2. Index Types](indexes-types.html) [11.3. Multicolumn Indexes](indexes-multicolumn.html) [11.4. Indexes and`ORDER BY`](indexes-ordering.html) [11.5. Combining Multiple Indexes](indexes-bitmap-scans.html) [11.6. Unique Indexes](indexes-unique.html) [11.7. Indexes on Expressions](indexes-expressional.html) [11.8. Partial Indexes](indexes-partial.html) [11.9. Index-Only Scans and Covering Indexes](indexes-index-only-scans.html) [11.10. Operator Classes and Operator Families](indexes-opclass.html) [11.11. Indexes and Collations](indexes-collations.html) [11.12. Examining Index Usage](indexes-examine.html) [12. Full Text Search](textsearch.html) [12.1. Introduction](textsearch-intro.html) [12.2. Tables and Indexes](textsearch-tables.html) [12.3. Controlling Text Search](textsearch-controls.html) [12.4. Additional Features](textsearch-features.html) [12.5. Parsers](textsearch-parsers.html) [12.6. Dictionaries](textsearch-dictionaries.html) [12.7. Configuration Example](textsearch-configuration.html) [12.8. Testing and Debugging Text Search](textsearch-debugging.html) [12.9. GIN and GiST Index Types](textsearch-indexes.html) [12.10. psql Support](textsearch-psql.html) [12.11. Limitations](textsearch-limitations.html) [13. Concurrency Control](mvcc.html) [13.1. Introduction](mvcc-intro.html) [13.2. Transaction Isolation](transaction-iso.html) [13.3. Explicit Locking](explicit-locking.html) [13.4. Data Consistency Checks at the Application Level](applevel-consistency.html) [13.5. Caveats](mvcc-caveats.html) [13.6. Locking and Indexes](locking-indexes.html) [14. Performance Tips](performance-tips.html) [14.1. Using`EXPLAIN`](using-explain.html) [14.2. Statistics Used by the Planner](planner-stats.html) [14.3. Controlling the Planner with Explicit`JOIN`Clauses](explicit-joins.html) [14.4. Populating a Database](populate.html) [14.5. Non-Durable Settings](non-durability.html) [15. Parallel Query](parallel-query.html) [15.1. How Parallel Query Works](how-parallel-query-works.html) [15.2. When Can Parallel Query Be Used?](when-can-parallel-query-be-used.html) [15.3. Parallel Plans](parallel-plans.html) [15.4. Parallel Safety](parallel-safety.html)