没有合适的资源?快使用搜索试试~ 我知道了~
首页PostgreSQL 9.6 使用手册:权威指南
PostgreSQL 9.6 使用手册:权威指南
需积分: 9 0 下载量 26 浏览量
更新于2024-07-16
收藏 6.39MB PDF 举报
"postgresql-9.6-A4.pdf 是 PostgreSQL 9.6 版本的使用说明书,由 PostgreSQL 全球开发团队编写并提供。该文档涵盖了 PostgreSQL 数据库管理系统的关键信息,包括安装、配置、使用和管理等内容。文档版权自1996年至2019年归 PostgreSQL 全球开发团队所有,基于开源协议允许自由使用、复制、修改和分发,但需保留版权声明。"
在 PostgreSQL 9.6 的这份文档中,用户可以了解到以下关键知识点:
1. **系统架构**:PostgreSQL 是一个对象关系型数据库管理系统(ORM),支持多种数据类型,如文本、数字、时间和空间数据等。其架构包含后端进程、前端进程、以及与操作系统交互的组件。
2. **安装与配置**:文档会详细解释如何在不同的操作系统上安装 PostgreSQL,包括设置环境变量、配置数据库参数、创建数据库集群等步骤。
3. **SQL语言支持**:PostgreSQL 支持 SQL 标准,包括 DDL(数据定义语言)、DML(数据操作语言)、以及事务控制和查询优化。
4. **安全性与权限**:讲解如何创建用户、角色和权限系统,以确保数据库的安全访问。包括 GRANT 和 REVOKE 命令,以及对数据的访问控制策略。
5. **备份与恢复**:介绍如何进行数据库备份,包括物理备份和逻辑备份,以及如何在系统故障后恢复数据。
6. **复制与高可用性**:PostgreSQL 提供了多种复制方式,如流复制和逻辑复制,用于实现数据同步和故障切换,确保高可用性。
7. **索引与查询优化**:详细解析如何创建和管理索引,以及使用 EXPLAIN 分析查询执行计划,优化查询性能。
8. **函数与过程**:涵盖内置函数和用户自定义函数的创建和使用,以及存储过程的概念和应用。
9. **触发器与规则**:讲解如何通过触发器和规则实现自动化的数据库操作,如数据验证和更新。
10. **性能监控与调优**:指导用户如何监控数据库性能,包括使用pg_stat视图和日志分析,以及调整参数来优化性能。
11. **错误处理与诊断**:提供错误代码和消息的解释,帮助用户理解和解决遇到的问题。
12. **扩展与插件**:介绍 PostgreSQL 的可扩展性,包括加载和使用第三方模块,如全文搜索、GIS支持等。
13. **维护与升级**:包括定期检查数据库健康状态、清理无用数据、以及从一个版本升级到另一个版本的流程。
通过这份 PostgreSQL 9.6 的文档,无论是初学者还是经验丰富的 DBA,都能获得全面且深入的理解,从而更好地管理和利用 PostgreSQL 数据库系统。
30.2. Write-Ahead Logging (WAL) .............................................................................. 711
30.3. Asynchronous Commit.........................................................................................711
30.4. WAL Configuration .............................................................................................. 713
30.5. WAL Internals ......................................................................................................716
31. Regression Tests................................................................................................................717
31.1. Running the Tests ................................................................................................. 717
31.1.1. Running the Tests Against a Temporary Installation ...............................717
31.1.2. Running the Tests Against an Existing Installation ................................. 717
31.1.3. Additional Test Suites..............................................................................718
31.1.4. Locale and Encoding................................................................................718
31.1.5. Extra Tests................................................................................................719
31.1.6. Testing Hot Standby.................................................................................719
31.2. Test Evaluation ..................................................................................................... 720
31.2.1. Error Message Differences.......................................................................720
31.2.2. Locale Differences................................................................................... 720
31.2.3. Date and Time Differences ...................................................................... 721
31.2.4. Floating-Point Differences.......................................................................721
31.2.5. Row Ordering Differences ....................................................................... 721
31.2.6. Insufficient Stack Depth...........................................................................722
31.2.7. The “random” Test...................................................................................722
31.2.8. Configuration Parameters.........................................................................722
31.3. Variant Comparison Files ..................................................................................... 722
31.4. TAP Tests.............................................................................................................. 723
31.5. Test Coverage Examination..................................................................................724
IV. Client Interfaces ....................................................................................................................... 725
32. libpq - C Library ...............................................................................................................727
32.1. Database Connection Control Functions..............................................................727
32.1.1. Connection Strings...................................................................................733
32.1.1.1. Keyword/Value Connection Strings ............................................733
32.1.1.2. Connection URIs.........................................................................734
32.1.2. Parameter Key Words .............................................................................. 734
32.2. Connection Status Functions ................................................................................ 738
32.3. Command Execution Functions ...........................................................................743
32.3.1. Main Functions ........................................................................................ 743
32.3.2. Retrieving Query Result Information ...................................................... 751
32.3.3. Retrieving Other Result Information .......................................................754
32.3.4. Escaping Strings for Inclusion in SQL Commands .................................755
32.4. Asynchronous Command Processing...................................................................757
32.5. Retrieving Query Results Row-By-Row .............................................................. 761
32.6. Canceling Queries in Progress.............................................................................. 762
32.7. The Fast-Path Interface.........................................................................................763
32.8. Asynchronous Notification...................................................................................764
32.9. Functions Associated with the COPY Command ..................................................765
32.9.1. Functions for Sending COPY Data............................................................766
32.9.2. Functions for Receiving COPY Data.........................................................767
32.9.3. Obsolete Functions for COPY ...................................................................767
32.10. Control Functions ............................................................................................... 769
32.11. Miscellaneous Functions ....................................................................................771
32.12. Notice Processing ............................................................................................... 773
32.13. Event System...................................................................................................... 774
32.13.1. Event Types............................................................................................ 774
xvi
32.13.2. Event Callback Procedure......................................................................776
32.13.3. Event Support Functions........................................................................777
32.13.4. Event Example....................................................................................... 778
32.14. Environment Variables .......................................................................................780
32.15. The Password File ..............................................................................................782
32.16. The Connection Service File ..............................................................................782
32.17. LDAP Lookup of Connection Parameters..........................................................783
32.18. SSL Support........................................................................................................784
32.18.1. Client Verification of Server Certificates ............................................... 784
32.18.2. Client Certificates...................................................................................785
32.18.3. Protection Provided in Different Modes ................................................785
32.18.4. SSL Client File Usage............................................................................787
32.18.5. SSL Library Initialization ......................................................................787
32.19. Behavior in Threaded Programs.........................................................................788
32.20. Building libpq Programs.....................................................................................789
32.21. Example Programs.............................................................................................. 790
33. Large Objects ....................................................................................................................800
33.1. Introduction ..........................................................................................................800
33.2. Implementation Features ......................................................................................800
33.3. Client Interfaces.................................................................................................... 800
33.3.1. Creating a Large Object........................................................................... 801
33.3.2. Importing a Large Object.........................................................................801
33.3.3. Exporting a Large Object.........................................................................802
33.3.4. Opening an Existing Large Object...........................................................802
33.3.5. Writing Data to a Large Object................................................................802
33.3.6. Reading Data from a Large Object ..........................................................803
33.3.7. Seeking in a Large Object........................................................................803
33.3.8. Obtaining the Seek Position of a Large Object........................................803
33.3.9. Truncating a Large Object ....................................................................... 804
33.3.10. Closing a Large Object Descriptor ........................................................804
33.3.11. Removing a Large Object ......................................................................804
33.4. Server-side Functions ...........................................................................................805
33.5. Example Program ................................................................................................. 806
34. ECPG - Embedded SQL in C............................................................................................812
34.1. The Concept.......................................................................................................... 812
34.2. Managing Database Connections .........................................................................812
34.2.1. Connecting to the Database Server.......................................................... 812
34.2.2. Choosing a Connection............................................................................ 814
34.2.3. Closing a Connection...............................................................................815
34.3. Running SQL Commands.....................................................................................815
34.3.1. Executing SQL Statements ......................................................................815
34.3.2. Using Cursors...........................................................................................816
34.3.3. Managing Transactions............................................................................ 817
34.3.4. Prepared Statements.................................................................................817
34.4. Using Host Variables ............................................................................................818
34.4.1. Overview..................................................................................................818
34.4.2. Declare Sections.......................................................................................818
34.4.3. Retrieving Query Results.........................................................................819
34.4.4. Type Mapping ..........................................................................................820
34.4.4.1. Handling Character Strings ......................................................... 821
34.4.4.2. Accessing Special Data Types..................................................... 821
34.4.4.2.1. timestamp, date............................................................... 822
xvii
34.4.4.2.2. interval ............................................................................ 822
34.4.4.2.3. numeric, decimal.............................................................823
34.4.4.3. Host Variables with Nonprimitive Types .................................... 824
34.4.4.3.1. Arrays .............................................................................824
34.4.4.3.2. Structures ........................................................................ 825
34.4.4.3.3. Typedefs..........................................................................826
34.4.4.3.4. Pointers ...........................................................................827
34.4.5. Handling Nonprimitive SQL Data Types.................................................827
34.4.5.1. Arrays..........................................................................................827
34.4.5.2. Composite Types .........................................................................829
34.4.5.3. User-defined Base Types .............................................................831
34.4.6. Indicators..................................................................................................832
34.5. Dynamic SQL.......................................................................................................832
34.5.1. Executing Statements without a Result Set ............................................. 832
34.5.2. Executing a Statement with Input Parameters ......................................... 833
34.5.3. Executing a Statement with a Result Set ................................................. 833
34.6. pgtypes Library.....................................................................................................834
34.6.1. Character Strings......................................................................................835
34.6.2. The numeric Type ....................................................................................835
34.6.3. The date Type........................................................................................... 837
34.6.4. The timestamp Type................................................................................. 841
34.6.5. The interval Type .....................................................................................844
34.6.6. The decimal Type..................................................................................... 845
34.6.7. errno Values of pgtypeslib .......................................................................845
34.6.8. Special Constants of pgtypeslib............................................................... 846
34.7. Using Descriptor Areas ........................................................................................847
34.7.1. Named SQL Descriptor Areas .................................................................847
34.7.2. SQLDA Descriptor Areas ........................................................................849
34.7.2.1. SQLDA Data Structure................................................................850
34.7.2.1.1. sqlda_t Structure ............................................................. 850
34.7.2.1.2. sqlvar_t Structure............................................................ 851
34.7.2.1.3. struct sqlname Structure .................................................851
34.7.2.2. Retrieving a Result Set Using an SQLDA ..................................852
34.7.2.3. Passing Query Parameters Using an SQLDA..............................853
34.7.2.4. A Sample Application Using SQLDA ........................................854
34.8. Error Handling...................................................................................................... 860
34.8.1. Setting Callbacks ..................................................................................... 860
34.8.2. sqlca ......................................................................................................... 862
34.8.3. SQLSTATE vs. SQLCODE........................................................................... 863
34.9. Preprocessor Directives ........................................................................................ 867
34.9.1. Including Files ......................................................................................... 867
34.9.2. The define and undef Directives .............................................................. 867
34.9.3. ifdef, ifndef, else, elif, and endif Directives.............................................868
34.10. Processing Embedded SQL Programs................................................................ 869
34.11. Library Functions ...............................................................................................870
34.12. Large Objects...................................................................................................... 870
34.13. C++ Applications ...............................................................................................872
34.13.1. Scope for Host Variables........................................................................872
34.13.2. C++ Application Development with External C Module ......................874
34.14. Embedded SQL Commands ...............................................................................876
ALLOCATE DESCRIPTOR ...............................................................................876
CONNECT...........................................................................................................878
xviii
DEALLOCATE DESCRIPTOR .......................................................................... 881
DECLARE ...........................................................................................................882
DESCRIBE ..........................................................................................................884
DISCONNECT ....................................................................................................885
EXECUTE IMMEDIATE....................................................................................887
GET DESCRIPTOR ............................................................................................ 888
OPEN ...................................................................................................................891
PREPARE ............................................................................................................893
SET AUTOCOMMIT .......................................................................................... 894
SET CONNECTION ........................................................................................... 895
SET DESCRIPTOR............................................................................................. 896
TYPE....................................................................................................................898
VAR...................................................................................................................... 900
WHENEVER .......................................................................................................901
34.15. Informix Compatibility Mode ............................................................................903
34.15.1. Additional Types....................................................................................903
34.15.2. Additional/Missing Embedded SQL Statements ...................................903
34.15.3. Informix-compatible SQLDA Descriptor Areas....................................904
34.15.4. Additional Functions..............................................................................907
34.15.5. Additional Constants..............................................................................915
34.16. Internals .............................................................................................................. 916
35. The Information Schema...................................................................................................919
35.1. The Schema ..........................................................................................................919
35.2. Data Types ............................................................................................................919
35.3. information_schema_catalog_name ...........................................................920
35.4. administrable_role_authorizations.......................................................920
35.5. applicable_roles............................................................................................920
35.6. attributes.........................................................................................................921
35.7. character_sets................................................................................................925
35.8. check_constraint_routine_usage .............................................................926
35.9. check_constraints ......................................................................................... 926
35.10. collations.......................................................................................................927
35.11. collation_character_set_applicability ............................................927
35.12. column_domain_usage ...................................................................................928
35.13. column_options..............................................................................................928
35.14. column_privileges ....................................................................................... 929
35.15. column_udt_usage..........................................................................................929
35.16. columns ............................................................................................................. 930
35.17. constraint_column_usage .......................................................................... 935
35.18. constraint_table_usage............................................................................. 936
35.19. data_type_privileges.................................................................................936
35.20. domain_constraints .....................................................................................937
35.21. domain_udt_usage..........................................................................................938
35.22. domains ............................................................................................................. 938
35.23. element_types ................................................................................................941
35.24. enabled_roles ................................................................................................944
35.25. foreign_data_wrapper_options................................................................945
35.26. foreign_data_wrappers...............................................................................945
35.27. foreign_server_options............................................................................. 945
35.28. foreign_servers............................................................................................946
35.29. foreign_table_options...............................................................................946
35.30. foreign_tables..............................................................................................947
xix
35.31. key_column_usage..........................................................................................947
35.32. parameters.......................................................................................................948
35.33. referential_constraints .......................................................................... 951
35.34. role_column_grants .....................................................................................952
35.35. role_routine_grants ...................................................................................952
35.36. role_table_grants ....................................................................................... 953
35.37. role_udt_grants............................................................................................954
35.38. role_usage_grants ....................................................................................... 954
35.39. routine_privileges .....................................................................................955
35.40. routines...........................................................................................................956
35.41. schemata...........................................................................................................962
35.42. sequences.........................................................................................................962
35.43. sql_features ..................................................................................................963
35.44. sql_implementation_info .......................................................................... 964
35.45. sql_languages ................................................................................................965
35.46. sql_packages ..................................................................................................965
35.47. sql_parts.........................................................................................................966
35.48. sql_sizing.......................................................................................................966
35.49. sql_sizing_profiles ...................................................................................967
35.50. table_constraints ....................................................................................... 967
35.51. table_privileges..........................................................................................968
35.52. tables ...............................................................................................................969
35.53. transforms.......................................................................................................970
35.54. triggered_update_columns ........................................................................ 971
35.55. triggers...........................................................................................................971
35.56. udt_privileges..............................................................................................973
35.57. usage_privileges..........................................................................................973
35.58. user_defined_types .....................................................................................974
35.59. user_mapping_options.................................................................................976
35.60. user_mappings ................................................................................................976
35.61. view_column_usage ....................................................................................... 977
35.62. view_routine_usage .....................................................................................978
35.63. view_table_usage..........................................................................................978
35.64. views .................................................................................................................979
V. Server Programming ................................................................................................................. 981
36. Extending SQL..................................................................................................................983
36.1. How Extensibility Works......................................................................................983
36.2. The PostgreSQL Type System..............................................................................983
36.2.1. Base Types ...............................................................................................983
36.2.2. Composite Types...................................................................................... 983
36.2.3. Domains ...................................................................................................984
36.2.4. Pseudo-Types ...........................................................................................984
36.2.5. Polymorphic Types ..................................................................................984
36.3. User-defined Functions.........................................................................................985
36.4. Query Language (SQL) Functions .......................................................................985
36.4.1. Arguments for SQL Functions.................................................................986
36.4.2. SQL Functions on Base Types.................................................................987
36.4.3. SQL Functions on Composite Types .......................................................989
36.4.4. SQL Functions with Output Parameters ..................................................991
36.4.5. SQL Functions with Variable Numbers of Arguments............................992
36.4.6. SQL Functions with Default Values for Arguments................................993
xx
剩余2618页未读,继续阅读
2020-04-17 上传
2020-10-29 上传
2019-08-13 上传
2024-01-29 上传
2023-05-16 上传
2024-01-22 上传
2023-06-09 上传
2023-07-09 上传
2023-06-03 上传
wuhansjjd
- 粉丝: 2
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- StarModAPI: StarMade 模组开发的Java API工具包
- PHP疫情上报管理系统开发与数据库实现详解
- 中秋节特献:明月祝福Flash动画素材
- Java GUI界面RPi-kee_Pilot:RPi-kee专用控制工具
- 电脑端APK信息提取工具APK Messenger功能介绍
- 探索矩阵连乘算法在C++中的应用
- Airflow教程:入门到工作流程创建
- MIP在Matlab中实现黑白图像处理的开源解决方案
- 图像切割感知分组框架:Matlab中的PG-framework实现
- 计算机科学中的经典算法与应用场景解析
- MiniZinc 编译器:高效解决离散优化问题
- MATLAB工具用于测量静态接触角的开源代码解析
- Python网络服务器项目合作指南
- 使用Matlab实现基础水族馆鱼类跟踪的代码解析
- vagga:基于Rust的用户空间容器化开发工具
- PPAP: 多语言支持的PHP邮政地址解析器项目
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功