没有合适的资源?快使用搜索试试~ 我知道了~
首页PostgreSQL 9.0.22 官方文档详解
PostgreSQL 9.0.22 官方文档详解
需积分: 9 3 下载量 152 浏览量
更新于2024-07-20
收藏 5.5MB PDF 举报
"PostgreSQL9.0.22官方文档,由PostgreSQL全球开发团队编写,版权自1996年至2015年,遵循加州大学的开源许可证条款。"
PostgreSQL是一种强大的开源关系型数据库管理系统,其版本9.0.22的文档详细介绍了该系统的各个方面。该文档由PostgreSQL全球开发团队编撰,旨在为用户提供全面的学习和参考材料。PostgreSQL的历史可以追溯到1994年的Postgres95,由加州大学的代表们持有版权。这份文档的使用、复制、修改和分发是被许可的,但需保留原有的版权信息。
文档中的法律通知强调了软件的使用风险,明确指出加州大学不对任何直接或间接、特殊或附带的损害负责,包括因使用该软件及其文档可能导致的利润损失。同时,加州大学不提供任何形式的保证,无论是明示的还是默示的。
在内容上,PostgreSQL 9.0.22的文档可能涵盖了以下知识点:
1. **安装与配置**:如何在不同的操作系统上安装PostgreSQL,设置数据库服务器,以及配置相关的参数。
2. **SQL语言支持**:PostgreSQL支持标准SQL,包括数据定义(DDL)、数据操纵(DML)、查询(SELECT)语句,以及事务控制等。
3. **数据类型**:介绍PostgreSQL支持的各种内置数据类型,如数值类型、字符串类型、日期/时间类型、数组类型、复合类型等。
4. **表和索引**:如何创建、修改和删除表,以及如何创建索引来优化查询性能。
5. **查询处理**:深入解析SQL查询的执行过程,包括查询优化器的工作原理。
6. **安全性与权限**:用户管理和权限控制系统,包括角色、权限、访问控制列表(ACL)等。
7. **并行与并发**:关于多线程和并发控制,如MVCC(多版本并发控制)机制。
8. **复制与高可用性**:如流复制、异步复制和哨兵系统,用于实现高可用性和灾难恢复。
9. **扩展性**:讨论如何开发和使用自定义函数、操作符、数据类型、索引方法等。
10. **备份与恢复**:最佳实践和工具,用于备份数据库和在必要时进行恢复。
11. **性能调优**:包括查询优化、统计收集、索引策略和硬件配置建议。
12. **服务器编程接口(SPI)**:允许内部过程调用SQL,扩展数据库功能。
13. **PL/pgSQL和其它过程语言**:PostgreSQL内建的PL/pgSQL语言和其他过程语言的使用。
14. **日志与监控**:如何设置和解读服务器日志,以及监控数据库性能的方法。
15. **故障排查**:常见问题的解决方法和诊断工具。
通过这份详尽的文档,用户不仅可以学习到PostgreSQL的基础知识,还能深入理解其高级特性,从而有效地设计、管理及优化数据库系统。对于开发者、DBA以及对数据库感兴趣的人员来说,这是一份宝贵的参考资料。
33.11.3. SQLSTATE vs SQLCODE.......................................................................... 673
33.12. Preprocessor directives....................................................................................... 676
33.12.1. Including files.........................................................................................676
33.12.2. The #define and #undef directives .........................................................676
33.12.3. ifdef, ifndef, else, elif, and endif directives ...........................................677
33.13. Processing Embedded SQL Programs................................................................ 677
33.14. Library Functions ...............................................................................................678
33.15. Internals .............................................................................................................. 679
34. The Information Schema...................................................................................................682
34.1. The Schema ..........................................................................................................682
34.2. Data Types ............................................................................................................682
34.3. information_schema_catalog_name ...........................................................682
34.4. administrable_role_authorizations.......................................................683
34.5. applicable_roles............................................................................................683
34.6. attributes.........................................................................................................684
34.7. check_constraint_routine_usage .............................................................686
34.8. check_constraints ......................................................................................... 687
34.9. column_domain_usage .....................................................................................687
34.10. column_privileges ....................................................................................... 688
34.11. column_udt_usage..........................................................................................689
34.12. columns ............................................................................................................. 689
34.13. constraint_column_usage .......................................................................... 694
34.14. constraint_table_usage............................................................................. 694
34.15. data_type_privileges................................................................................. 695
34.16. domain_constraints .....................................................................................696
34.17. domain_udt_usage..........................................................................................696
34.18. domains ............................................................................................................. 697
34.19. element_types ................................................................................................ 699
34.20. enabled_roles ................................................................................................ 702
34.21. foreign_data_wrapper_options................................................................702
34.22. foreign_data_wrappers............................................................................... 703
34.23. foreign_server_options............................................................................. 703
34.24. foreign_servers............................................................................................704
34.25. key_column_usage..........................................................................................704
34.26. parameters.......................................................................................................705
34.27. referential_constraints .......................................................................... 708
34.28. role_column_grants .....................................................................................709
34.29. role_routine_grants ...................................................................................709
34.30. role_table_grants ....................................................................................... 710
34.31. role_usage_grants ....................................................................................... 711
34.32. routine_privileges .....................................................................................711
34.33. routines...........................................................................................................712
34.34. schemata...........................................................................................................718
34.35. sequences.........................................................................................................718
34.36. sql_features ..................................................................................................719
34.37. sql_implementation_info .......................................................................... 720
34.38. sql_languages ................................................................................................ 721
34.39. sql_packages ..................................................................................................721
34.40. sql_parts.........................................................................................................722
34.41. sql_sizing.......................................................................................................722
34.42. sql_sizing_profiles ...................................................................................723
34.43. table_constraints ....................................................................................... 723
xvi
34.44. table_privileges..........................................................................................724
34.45. tables ...............................................................................................................725
34.46. triggered_update_columns ........................................................................ 725
34.47. triggers...........................................................................................................726
34.48. usage_privileges..........................................................................................728
34.49. user_mapping_options................................................................................. 728
34.50. user_mappings ................................................................................................ 729
34.51. view_column_usage ....................................................................................... 729
34.52. view_routine_usage .....................................................................................730
34.53. view_table_usage..........................................................................................730
34.54. views .................................................................................................................731
V. Server Programming ................................................................................................................. 733
35. Extending SQL..................................................................................................................735
35.1. How Extensibility Works......................................................................................735
35.2. The PostgreSQL Type System.............................................................................. 735
35.2.1. Base Types ...............................................................................................735
35.2.2. Composite Types......................................................................................735
35.2.3. Domains ...................................................................................................736
35.2.4. Pseudo-Types ........................................................................................... 736
35.2.5. Polymorphic Types ..................................................................................736
35.3. User-Defined Functions........................................................................................ 737
35.4. Query Language (SQL) Functions .......................................................................737
35.4.1. SQL Functions on Base Types................................................................. 738
35.4.2. SQL Functions on Composite Types .......................................................740
35.4.3. SQL Functions with Parameter Names.................................................... 743
35.4.4. SQL Functions with Output Parameters ..................................................743
35.4.5. SQL Functions with Variable Numbers of Arguments............................ 744
35.4.6. SQL Functions with Default Values for Arguments................................ 745
35.4.7. SQL Functions as Table Sources .............................................................746
35.4.8. SQL Functions Returning Sets ................................................................746
35.4.9. SQL Functions Returning TABLE ............................................................748
35.4.10. Polymorphic SQL Functions .................................................................748
35.5. Function Overloading........................................................................................... 750
35.6. Function Volatility Categories..............................................................................751
35.7. Procedural Language Functions ...........................................................................752
35.8. Internal Functions................................................................................................. 752
35.9. C-Language Functions.......................................................................................... 753
35.9.1. Dynamic Loading.....................................................................................753
35.9.2. Base Types in C-Language Functions......................................................754
35.9.3. Version 0 Calling Conventions ................................................................757
35.9.4. Version 1 Calling Conventions ................................................................759
35.9.5. Writing Code............................................................................................762
35.9.6. Compiling and Linking Dynamically-Loaded Functions ........................763
35.9.7. Extension Building Infrastructure............................................................ 765
35.9.8. Composite-Type Arguments .................................................................... 767
35.9.9. Returning Rows (Composite Types) ........................................................ 768
35.9.10. Returning Sets........................................................................................770
35.9.11. Polymorphic Arguments and Return Types........................................... 775
35.9.12. Shared Memory and LWLocks .............................................................. 776
35.10. User-Defined Aggregates ...................................................................................777
35.11. User-Defined Types ............................................................................................ 779
xvii
35.12. User-Defined Operators......................................................................................783
35.13. Operator Optimization Information....................................................................784
35.13.1. COMMUTATOR.......................................................................................... 784
35.13.2. NEGATOR ................................................................................................ 785
35.13.3. RESTRICT ..............................................................................................785
35.13.4. JOIN.......................................................................................................786
35.13.5. HASHES...................................................................................................786
35.13.6. MERGES...................................................................................................787
35.14. Interfacing Extensions To Indexes......................................................................788
35.14.1. Index Methods and Operator Classes ....................................................788
35.14.2. Index Method Strategies ........................................................................ 789
35.14.3. Index Method Support Routines ............................................................790
35.14.4. An Example ........................................................................................... 792
35.14.5. Operator Classes and Operator Families................................................794
35.14.6. System Dependencies on Operator Classes ...........................................797
35.14.7. Special Features of Operator Classes.....................................................797
35.15. Using C++ for Extensibility ............................................................................... 798
36. Triggers ............................................................................................................................. 800
36.1. Overview of Trigger Behavior..............................................................................800
36.2. Visibility of Data Changes....................................................................................801
36.3. Writing Trigger Functions in C ............................................................................802
36.4. A Complete Trigger Example............................................................................... 804
37. The Rule System ...............................................................................................................809
37.1. The Query Tree.....................................................................................................809
37.2. Views and the Rule System ..................................................................................811
37.2.1. How SELECT Rules Work........................................................................ 811
37.2.2. View Rules in Non-SELECT Statements ..................................................816
37.2.3. The Power of Views in PostgreSQL ........................................................ 817
37.2.4. Updating a View.......................................................................................817
37.3. Rules on INSERT, UPDATE, and DELETE .............................................................817
37.3.1. How Update Rules Work .........................................................................817
37.3.1.1. A First Rule Step by Step............................................................ 819
37.3.2. Cooperation with Views...........................................................................822
37.4. Rules and Privileges .............................................................................................827
37.5. Rules and Command Status.................................................................................. 829
37.6. Rules versus Triggers ...........................................................................................829
38. Procedural Languages.......................................................................................................833
38.1. Installing Procedural Languages ..........................................................................833
39. PL/pgSQL - SQL Procedural Language ........................................................................... 836
39.1. Overview ..............................................................................................................836
39.1.1. Advantages of Using PL/pgSQL ............................................................. 836
39.1.2. Supported Argument and Result Data Types........................................... 836
39.2. Structure of PL/pgSQL......................................................................................... 837
39.3. Declarations.......................................................................................................... 838
39.3.1. Declaring Function Parameters................................................................ 839
39.3.2. ALIAS.......................................................................................................841
39.3.3. Copying Types .........................................................................................842
39.3.4. Row Types................................................................................................842
39.3.5. Record Types ........................................................................................... 843
39.4. Expressions........................................................................................................... 843
39.5. Basic Statements...................................................................................................844
39.5.1. Assignment .............................................................................................. 844
xviii
39.5.2. Executing a Command With No Result................................................... 844
39.5.3. Executing a Query with a Single-Row Result ......................................... 845
39.5.4. Executing Dynamic Commands .............................................................. 846
39.5.5. Obtaining the Result Status......................................................................849
39.5.6. Doing Nothing At All .............................................................................. 850
39.6. Control Structures.................................................................................................850
39.6.1. Returning From a Function......................................................................850
39.6.1.1. RETURN........................................................................................851
39.6.1.2. RETURN NEXT and RETURN QUERY ........................................... 851
39.6.2. Conditionals.............................................................................................852
39.6.2.1. IF-THEN......................................................................................853
39.6.2.2. IF-THEN-ELSE ........................................................................... 853
39.6.2.3. IF-THEN-ELSIF.........................................................................853
39.6.2.4. Simple CASE................................................................................854
39.6.2.5. Searched CASE............................................................................. 855
39.6.3. Simple Loops ...........................................................................................855
39.6.3.1. LOOP ............................................................................................ 856
39.6.3.2. EXIT ............................................................................................ 856
39.6.3.3. CONTINUE....................................................................................857
39.6.3.4. WHILE .......................................................................................... 857
39.6.3.5. FOR (integer variant)....................................................................857
39.6.4. Looping Through Query Results ............................................................. 858
39.6.5. Trapping Errors........................................................................................859
39.7. Cursors..................................................................................................................861
39.7.1. Declaring Cursor Variables...................................................................... 861
39.7.2. Opening Cursors ...................................................................................... 862
39.7.2.1. OPEN FOR query........................................................................ 862
39.7.2.2. OPEN FOR EXECUTE ..................................................................863
39.7.2.3. Opening a Bound Cursor.............................................................863
39.7.3. Using Cursors...........................................................................................863
39.7.3.1. FETCH .......................................................................................... 864
39.7.3.2. MOVE ............................................................................................ 864
39.7.3.3. UPDATE/DELETE WHERE CURRENT OF .................................... 865
39.7.3.4. CLOSE .......................................................................................... 865
39.7.3.5. Returning Cursors .......................................................................865
39.7.4. Looping Through a Cursor’s Result.........................................................867
39.8. Errors and Messages............................................................................................. 867
39.9. Trigger Procedures ...............................................................................................868
39.10. PL/pgSQL Under the Hood................................................................................ 874
39.10.1. Variable Substitution.............................................................................. 874
39.10.2. Plan Caching ..........................................................................................876
39.11. Tips for Developing in PL/pgSQL......................................................................878
39.11.1. Handling of Quotation Marks ................................................................878
39.12. Porting from Oracle PL/SQL.............................................................................. 880
39.12.1. Porting Examples...................................................................................880
39.12.2. Other Things to Watch For..................................................................... 885
39.12.2.1. Implicit Rollback after Exceptions............................................886
39.12.2.2. EXECUTE....................................................................................886
39.12.2.3. Optimizing PL/pgSQL Functions.............................................. 886
39.12.3. Appendix................................................................................................ 886
40. PL/Tcl - Tcl Procedural Language....................................................................................890
40.1. Overview ..............................................................................................................890
xix
40.2. PL/Tcl Functions and Arguments.........................................................................890
40.3. Data Values in PL/Tcl...........................................................................................891
40.4. Global Data in PL/Tcl ..........................................................................................892
40.5. Database Access from PL/Tcl ..............................................................................892
40.6. Trigger Procedures in PL/Tcl ...............................................................................894
40.7. Modules and the unknown command................................................................... 896
40.8. Tcl Procedure Names ...........................................................................................896
41. PL/Perl - Perl Procedural Language.................................................................................. 898
41.1. PL/Perl Functions and Arguments........................................................................ 898
41.2. Data Values in PL/Perl..........................................................................................901
41.3. Built-in Functions................................................................................................. 901
41.3.1. Database Access from PL/Perl.................................................................901
41.3.2. Utility functions in PL/Perl......................................................................904
41.4. Global Values in PL/Perl ...................................................................................... 905
41.5. Trusted and Untrusted PL/Perl .............................................................................906
41.6. PL/Perl Triggers ...................................................................................................907
41.7. PL/Perl Under the Hood ....................................................................................... 909
41.7.1. Configuration ........................................................................................... 909
41.7.2. Limitations and Missing Features............................................................910
42. PL/Python - Python Procedural Language........................................................................911
42.1. Python 2 vs. Python 3........................................................................................... 911
42.2. PL/Python Functions ............................................................................................912
42.3. Data Values...........................................................................................................913
42.3.1. Data Type Mapping..................................................................................913
42.3.2. Null, None................................................................................................ 914
42.3.3. Arrays, Lists.............................................................................................915
42.3.4. Composite Types......................................................................................915
42.3.5. Set-Returning Functions .......................................................................... 917
42.4. Sharing Data ......................................................................................................... 918
42.5. Anonymous Code Blocks..................................................................................... 918
42.6. Trigger Functions .................................................................................................919
42.7. Database Access ................................................................................................... 919
42.8. Utility Functions................................................................................................... 920
42.9. Environment Variables .........................................................................................921
43. Server Programming Interface..........................................................................................922
43.1. Interface Functions ............................................................................................... 922
SPI_connect ......................................................................................................... 922
SPI_finish.............................................................................................................924
SPI_push ..............................................................................................................925
SPI_pop................................................................................................................926
SPI_execute..........................................................................................................927
SPI_exec...............................................................................................................930
SPI_execute_with_args........................................................................................931
SPI_prepare.......................................................................................................... 933
SPI_prepare_cursor.............................................................................................. 935
SPI_prepare_params ............................................................................................936
SPI_getargcount...................................................................................................937
SPI_getargtypeid.................................................................................................. 938
SPI_is_cursor_plan ..............................................................................................939
SPI_execute_plan.................................................................................................940
SPI_execute_plan_with_paramlist....................................................................... 942
SPI_execp.............................................................................................................943
xx
剩余2400页未读,继续阅读
2012-09-14 上传
2020-04-10 上传
2010-08-11 上传
2009-05-19 上传
2015-08-07 上传
2011-10-18 上传
2009-09-18 上传
2023-07-27 上传
2021-09-30 上传
pygdrasil
- 粉丝: 56
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 俄罗斯RTSD数据集实现交通标志实时检测
- 易语言开发的文件批量改名工具使用Ex_Dui美化界面
- 爱心援助动态网页教程:前端开发实战指南
- 复旦微电子数字电路课件4章同步时序电路详解
- Dylan Manley的编程投资组合登录页面设计介绍
- Python实现H3K4me3与H3K27ac表观遗传标记域长度分析
- 易语言开源播放器项目:简易界面与强大的音频支持
- 介绍rxtx2.2全系统环境下的Java版本使用
- ZStack-CC2530 半开源协议栈使用与安装指南
- 易语言实现的八斗平台与淘宝评论采集软件开发
- Christiano响应式网站项目设计与技术特点
- QT图形框架中QGraphicRectItem的插入与缩放技术
- 组合逻辑电路深入解析与习题教程
- Vue+ECharts实现中国地图3D展示与交互功能
- MiSTer_MAME_SCRIPTS:自动下载MAME与HBMAME脚本指南
- 前端技术精髓:构建响应式盆栽展示网站
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功