没有合适的资源?快使用搜索试试~ 我知道了~
首页PostgreSQL 9.0.4 官方文档详解
PostgreSQL 9.0.4 官方文档详解
需积分: 10 2 下载量 101 浏览量
更新于2024-07-24
收藏 7.8MB PDF 举报
"PostgreSQL 9.0是 PostgreSQL 全球开发团队发布的一个版本,提供了英文版的数据库管理系统文档。这个版本的文档详细介绍了 PostgreSQL 9.0.4 的各项功能、特性和使用方法。PostgreSQL 是一个开源的关系型数据库管理系统,自1996年以来持续发展,遵循加州大学的授权许可协议。文档涵盖了数据库的安装、配置、SQL语言、性能优化、安全性以及故障排除等多个方面,旨在帮助用户和开发者更好地理解和操作 PostgreSQL 数据库系统。"
在 PostgreSQL 9.0 版本中,引入了许多重要的改进和新特性,包括:
1. **并行查询**:这一版本引入了对并行查询的支持,提高了大型数据集处理的性能,尤其是在执行聚合和索引扫描时。
2. **窗口函数增强**:窗口函数的扩展使得在复杂查询中进行分析和排序更为便捷,如`RANK()`, `ROW_NUMBER()`, 和 `LAG()`/`LEAD()` 函数等。
3. **复制与流复制增强**:复制功能得到了增强,支持物理复制和逻辑复制,允许数据实时同步到多个副本,增强了高可用性和灾难恢复能力。
4. **多版本并发控制(MVCC)改进**:MVCC 在 9.0 版本中进行了优化,提升了并发性能,减少了死锁的可能性,并改善了事务隔离级别的实现。
5. **外键约束的性能提升**:外键检查的性能得到显著提升,尤其是在有大量约束的表上进行插入和更新操作时。
6. **分区表**:9.0 版本引入了范围分区,使得大型表的管理和查询更加高效,可以根据特定列的值或范围将数据分布到不同的子表中。
7. **JSON 支持**:增加了对 JSON 数据类型的支持,使得 PostgreSQL 能够处理非结构化的数据,适应 NoSQL 风格的应用场景。
8. **PL/v8 语言**:引入了 PL/v8,这是一种基于 JavaScript 的过程语言,允许用户编写存储过程和触发器,利用 JavaScript 的灵活性。
9. **性能监控工具**:提供了一些新的性能监控和诊断工具,如`pg_stat_statements`扩展,可以帮助管理员跟踪查询性能。
10. **安全性和权限管理**:加强了角色和权限的管理,提供了更细粒度的访问控制,如`SECURITY DEFINER` 规范和 `INVOKER RIGHTS` 规范。
此外,PostgreSQL 9.0 还包含许多其他改进,例如对 Unicode 的更好支持、新的索引类型、更高效的索引扫描策略、改进的备份和恢复选项,以及对 SQL 标准的更多兼容性等。这些特性使得 PostgreSQL 成为了一个功能强大、可扩展且高度可靠的数据库系统,适合各种规模的企业级应用。
33.12. Preprocessor directives ....................................................................................... 671
33.12.1. Including files......................................................................................... 671
33.12.2. The #define and #undef directives ......................................................... 671
33.12.3. ifdef, ifndef, else, elif, and endif directives ...........................................672
33.13. Processing Embedded SQL Programs................................................................ 672
33.14. Library Functions ............................................................................................... 673
33.15. Internals .............................................................................................................. 674
34. The Information Schema................................................................................................... 677
34.1. The Schema .......................................................................................................... 677
34.2. Data Types ............................................................................................................ 677
34.3. information_schema_catalog_name ...........................................................677
34.4. administrable_role_authorizations....................................................... 678
34.5. applicable_roles............................................................................................ 678
34.6. attributes......................................................................................................... 679
34.7. check_constraint_routine_usage ............................................................. 681
34.8. check_constraints ......................................................................................... 682
34.9. column_domain_usage ..................................................................................... 682
34.10. column_privileges ....................................................................................... 683
34.11. column_udt_usage.......................................................................................... 684
34.12. columns ............................................................................................................. 684
34.13. constraint_column_usage .......................................................................... 689
34.14. constraint_table_usage............................................................................. 689
34.15. data_type_privileges................................................................................. 690
34.16. domain_constraints ..................................................................................... 691
34.17. domain_udt_usage.......................................................................................... 691
34.18. domains ............................................................................................................. 692
34.19. element_types ................................................................................................ 694
34.20. enabled_roles ................................................................................................ 697
34.21. foreign_data_wrapper_options................................................................ 697
34.22. foreign_data_wrappers............................................................................... 698
34.23. foreign_server_options............................................................................. 698
34.24. foreign_servers............................................................................................ 699
34.25. key_column_usage.......................................................................................... 699
34.26. parameters....................................................................................................... 700
34.27. referential_constraints .......................................................................... 703
34.28. role_column_grants ..................................................................................... 704
34.29. role_routine_grants ................................................................................... 704
34.30. role_table_grants ....................................................................................... 705
34.31. role_usage_grants ....................................................................................... 706
34.32. routine_privileges ..................................................................................... 706
34.33. routines........................................................................................................... 707
34.34. schemata........................................................................................................... 713
34.35. sequences......................................................................................................... 713
34.36. sql_features .................................................................................................. 714
34.37. sql_implementation_info .......................................................................... 715
34.38. sql_languages ................................................................................................ 716
34.39. sql_packages .................................................................................................. 716
34.40. sql_parts......................................................................................................... 717
34.41. sql_sizing....................................................................................................... 717
34.42. sql_sizing_profiles ................................................................................... 718
34.43. table_constraints ....................................................................................... 718
34.44. table_privileges.......................................................................................... 719
xvi
34.45. tables ...............................................................................................................720
34.46. triggered_update_columns ........................................................................ 720
34.47. triggers........................................................................................................... 721
34.48. usage_privileges.......................................................................................... 723
34.49. user_mapping_options................................................................................. 723
34.50. user_mappings ................................................................................................ 724
34.51. view_column_usage ....................................................................................... 724
34.52. view_routine_usage ..................................................................................... 725
34.53. view_table_usage.......................................................................................... 725
34.54. views ................................................................................................................. 726
V. Server Programming ................................................................................................................. 728
35. Extending SQL.................................................................................................................. 730
35.1. How Extensibility Works...................................................................................... 730
35.2. The PostgreSQL Type System.............................................................................. 730
35.2.1. Base Types ............................................................................................... 730
35.2.2. Composite Types...................................................................................... 730
35.2.3. Domains ................................................................................................... 731
35.2.4. Pseudo-Types ........................................................................................... 731
35.2.5. Polymorphic Types ..................................................................................731
35.3. User-Defined Functions........................................................................................ 732
35.4. Query Language (SQL) Functions ....................................................................... 732
35.4.1. SQL Functions on Base Types ................................................................. 733
35.4.2. SQL Functions on Composite Types .......................................................735
35.4.3. SQL Functions with Parameter Names.................................................... 738
35.4.4. SQL Functions with Output Parameters .................................................. 738
35.4.5. SQL Functions with Variable Numbers of Arguments ............................ 739
35.4.6. SQL Functions with Default Values for Arguments ................................ 740
35.4.7. SQL Functions as Table Sources .............................................................741
35.4.8. SQL Functions Returning Sets ................................................................ 741
35.4.9. SQL Functions Returning TABLE ............................................................ 743
35.4.10. Polymorphic SQL Functions ................................................................. 743
35.5. Function Overloading........................................................................................... 745
35.6. Function Volatility Categories.............................................................................. 746
35.7. Procedural Language Functions ........................................................................... 747
35.8. Internal Functions................................................................................................. 747
35.9. C-Language Functions.......................................................................................... 748
35.9.1. Dynamic Loading..................................................................................... 748
35.9.2. Base Types in C-Language Functions...................................................... 749
35.9.3. Version 0 Calling Conventions ................................................................752
35.9.4. Version 1 Calling Conventions ................................................................754
35.9.5. Writing Code............................................................................................ 757
35.9.6. Compiling and Linking Dynamically-Loaded Functions ........................ 757
35.9.7. Extension Building Infrastructure............................................................ 759
35.9.8. Composite-Type Arguments .................................................................... 761
35.9.9. Returning Rows (Composite Types) ........................................................ 763
35.9.10. Returning Sets........................................................................................ 765
35.9.11. Polymorphic Arguments and Return Types ........................................... 769
35.9.12. Shared Memory and LWLocks .............................................................. 771
35.10. User-Defined Aggregates ...................................................................................772
35.11. User-Defined Types ............................................................................................ 774
35.12. User-Defined Operators...................................................................................... 777
xvii
35.13. Operator Optimization Information.................................................................... 778
35.13.1. COMMUTATOR.......................................................................................... 778
35.13.2. NEGATOR ................................................................................................ 779
35.13.3. RESTRICT .............................................................................................. 779
35.13.4. JOIN....................................................................................................... 780
35.13.5. HASHES................................................................................................... 781
35.13.6. MERGES................................................................................................... 782
35.14. Interfacing Extensions To Indexes...................................................................... 782
35.14.1. Index Methods and Operator Classes ....................................................782
35.14.2. Index Method Strategies ........................................................................ 783
35.14.3. Index Method Support Routines ............................................................ 784
35.14.4. An Example ........................................................................................... 786
35.14.5. Operator Classes and Operator Families................................................ 788
35.14.6. System Dependencies on Operator Classes ........................................... 791
35.14.7. Special Features of Operator Classes..................................................... 792
35.15. Using C++ for Extensibility ............................................................................... 792
36. Triggers ............................................................................................................................. 794
36.1. Overview of Trigger Behavior.............................................................................. 794
36.2. Visibility of Data Changes.................................................................................... 795
36.3. Writing Trigger Functions in C ............................................................................ 796
36.4. A Complete Trigger Example............................................................................... 798
37. The Rule System ............................................................................................................... 803
37.1. The Query Tree..................................................................................................... 803
37.2. Views and the Rule System .................................................................................. 805
37.2.1. How SELECT Rules Work ........................................................................ 805
37.2.2. View Rules in Non-SELECT Statements .................................................. 810
37.2.3. The Power of Views in PostgreSQL ........................................................ 811
37.2.4. Updating a View.......................................................................................811
37.3. Rules on INSERT, UPDATE, and DELETE ............................................................. 811
37.3.1. How Update Rules Work .........................................................................811
37.3.1.1. A First Rule Step by Step............................................................ 813
37.3.2. Cooperation with Views........................................................................... 816
37.4. Rules and Privileges ............................................................................................. 821
37.5. Rules and Command Status.................................................................................. 823
37.6. Rules versus Triggers ........................................................................................... 823
38. Procedural Languages ....................................................................................................... 827
38.1. Installing Procedural Languages .......................................................................... 827
39. PL/pgSQL - SQL Procedural Language ........................................................................... 830
39.1. Overview ..............................................................................................................830
39.1.1. Advantages of Using PL/pgSQL ............................................................. 830
39.1.2. Supported Argument and Result Data Types........................................... 830
39.2. Structure of PL/pgSQL......................................................................................... 831
39.3. Declarations.......................................................................................................... 832
39.3.1. Declaring Function Parameters................................................................ 833
39.3.2. ALIAS....................................................................................................... 835
39.3.3. Copying Types ......................................................................................... 836
39.3.4. Row Types................................................................................................ 836
39.3.5. Record Types ........................................................................................... 837
39.4. Expressions........................................................................................................... 837
39.5. Basic Statements................................................................................................... 838
39.5.1. Assignment .............................................................................................. 838
39.5.2. Executing a Command With No Result ................................................... 838
xviii
39.5.3. Executing a Query with a Single-Row Result ......................................... 839
39.5.4. Executing Dynamic Commands .............................................................. 840
39.5.5. Obtaining the Result Status...................................................................... 843
39.5.6. Doing Nothing At All .............................................................................. 844
39.6. Control Structures................................................................................................. 844
39.6.1. Returning From a Function...................................................................... 844
39.6.1.1. RETURN........................................................................................ 844
39.6.1.2. RETURN NEXT and RETURN QUERY ........................................... 845
39.6.2. Conditionals ............................................................................................. 846
39.6.2.1. IF-THEN...................................................................................... 846
39.6.2.2. IF-THEN-ELSE ........................................................................... 847
39.6.2.3. IF-THEN-ELSIF......................................................................... 847
39.6.2.4. Simple CASE................................................................................ 848
39.6.2.5. Searched CASE............................................................................. 849
39.6.3. Simple Loops ........................................................................................... 849
39.6.3.1. LOOP ............................................................................................ 849
39.6.3.2. EXIT ............................................................................................ 850
39.6.3.3. CONTINUE.................................................................................... 850
39.6.3.4. WHILE .......................................................................................... 851
39.6.3.5. FOR (integer variant).................................................................... 851
39.6.4. Looping Through Query Results ............................................................. 852
39.6.5. Trapping Errors........................................................................................ 853
39.7. Cursors.................................................................................................................. 855
39.7.1. Declaring Cursor Variables ...................................................................... 855
39.7.2. Opening Cursors ...................................................................................... 856
39.7.2.1. OPEN FOR query........................................................................ 856
39.7.2.2. OPEN FOR EXECUTE .................................................................. 856
39.7.2.3. Opening a Bound Cursor............................................................. 857
39.7.3. Using Cursors........................................................................................... 857
39.7.3.1. FETCH .......................................................................................... 857
39.7.3.2. MOVE ............................................................................................ 858
39.7.3.3. UPDATE/DELETE WHERE CURRENT OF .................................... 858
39.7.3.4. CLOSE .......................................................................................... 859
39.7.3.5. Returning Cursors .......................................................................859
39.7.4. Looping Through a Cursor’s Result......................................................... 860
39.8. Errors and Messages............................................................................................. 861
39.9. Trigger Procedures ...............................................................................................862
39.10. PL/pgSQL Under the Hood ................................................................................ 867
39.10.1. Variable Substitution.............................................................................. 868
39.10.2. Plan Caching .......................................................................................... 870
39.11. Tips for Developing in PL/pgSQL......................................................................871
39.11.1. Handling of Quotation Marks ................................................................ 872
39.12. Porting from Oracle PL/SQL.............................................................................. 873
39.12.1. Porting Examples................................................................................... 874
39.12.2. Other Things to Watch For..................................................................... 879
39.12.2.1. Implicit Rollback after Exceptions............................................ 879
39.12.2.2. EXECUTE.................................................................................... 880
39.12.2.3. Optimizing PL/pgSQL Functions.............................................. 880
39.12.3. Appendix................................................................................................ 880
40. PL/Tcl - Tcl Procedural Language.................................................................................... 883
40.1. Overview ..............................................................................................................883
40.2. PL/Tcl Functions and Arguments......................................................................... 883
xix
40.3. Data Values in PL/Tcl........................................................................................... 884
40.4. Global Data in PL/Tcl ..........................................................................................885
40.5. Database Access from PL/Tcl .............................................................................. 885
40.6. Trigger Procedures in PL/Tcl ............................................................................... 887
40.7. Modules and the unknown command................................................................... 889
40.8. Tcl Procedure Names ...........................................................................................889
41. PL/Perl - Perl Procedural Language.................................................................................. 891
41.1. PL/Perl Functions and Arguments........................................................................ 891
41.2. Data Values in PL/Perl.......................................................................................... 894
41.3. Built-in Functions................................................................................................. 894
41.3.1. Database Access from PL/Perl................................................................. 894
41.3.2. Utility functions in PL/Perl...................................................................... 897
41.4. Global Values in PL/Perl ...................................................................................... 898
41.5. Trusted and Untrusted PL/Perl ............................................................................. 899
41.6. PL/Perl Triggers ...................................................................................................900
41.7. PL/Perl Under the Hood ....................................................................................... 902
41.7.1. Configuration ........................................................................................... 902
41.7.2. Limitations and Missing Features............................................................ 903
42. PL/Python - Python Procedural Language........................................................................ 904
42.1. Python 2 vs. Python 3........................................................................................... 904
42.2. PL/Python Functions ............................................................................................ 905
42.3. Data Values........................................................................................................... 906
42.3.1. Data Type Mapping.................................................................................. 906
42.3.2. Null, None................................................................................................ 907
42.3.3. Arrays, Lists............................................................................................. 908
42.3.4. Composite Types...................................................................................... 908
42.3.5. Set-Returning Functions .......................................................................... 910
42.4. Sharing Data ......................................................................................................... 911
42.5. Anonymous Code Blocks ..................................................................................... 911
42.6. Trigger Functions .................................................................................................912
42.7. Database Access ................................................................................................... 912
42.8. Utility Functions................................................................................................... 913
42.9. Environment Variables ......................................................................................... 914
43. Server Programming Interface .......................................................................................... 915
43.1. Interface Functions ............................................................................................... 915
SPI_connect ......................................................................................................... 915
SPI_finish............................................................................................................. 917
SPI_push .............................................................................................................. 918
SPI_pop................................................................................................................ 919
SPI_execute.......................................................................................................... 920
SPI_exec............................................................................................................... 923
SPI_execute_with_args........................................................................................ 924
SPI_prepare.......................................................................................................... 926
SPI_prepare_cursor.............................................................................................. 928
SPI_prepare_params ............................................................................................ 929
SPI_getargcount................................................................................................... 930
SPI_getargtypeid.................................................................................................. 931
SPI_is_cursor_plan .............................................................................................. 932
SPI_execute_plan................................................................................................. 933
SPI_execute_plan_with_paramlist....................................................................... 935
SPI_execp............................................................................................................. 936
SPI_cursor_open.................................................................................................. 937
xx
剩余2303页未读,继续阅读
点击了解资源详情
点击了解资源详情
点击了解资源详情
2011-10-29 上传
2012-11-17 上传
2012-05-10 上传
2010-12-21 上传
IT_TOM
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的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直接复制
信息提交成功