没有合适的资源?快使用搜索试试~ 我知道了~
首页Oracle数据库数据卡开发者指南11g Release 2
Oracle数据库数据卡开发者指南11g Release 2
需积分: 5 0 下载量 194 浏览量
更新于2024-06-25
收藏 5.12MB PDF 举报
"Oracle Database Data Cartridge Developer's Guide 11g Release 2 (11.2) - 370"
Oracle Database Data Cartridge Developer's Guide 11g Release 2 是一本针对开发人员的专业指南,专注于Oracle数据库的自定义数据存储和处理功能。这个文档版本(11.2)提供了关于如何利用Oracle数据库的数据卡匣(Data Cartridge)机制扩展数据库功能的详细信息。
数据卡匣是Oracle数据库的一个关键特性,它允许开发者创建自己的数据访问和处理模块,以满足特定的业务需求或性能优化。这些模块可以是C或C++编写的动态链接库,通过Oracle数据库的API与数据库交互。通过数据卡匣,开发者可以实现以下目标:
1. **自定义数据类型**:创建并支持新的数据类型,这些数据类型可能在标准SQL中不存在,但对特定应用至关重要。例如,开发者可以创建一个用于处理地理空间信息的自定义数据类型。
2. **存储过程和函数**:编写高效的本地代码来执行特定操作,这比在PL/SQL中编写相同功能可能更高效,特别是对于计算密集型任务。
3. **索引技术**:实现自定义索引方法,以加速特定查询的性能。例如,可以创建一个针对XML数据的特殊索引来提高搜索效率。
4. **事务处理和并发控制**:定义自己的事务处理逻辑,以适应特定应用的并发模型。
5. **数据转换和加载**:设计定制的数据加载工具,用于高效地导入大量数据,或者在不同格式间转换数据。
6. **分区和分片策略**:实现高级的分区策略,如范围、列表或哈希分区,以优化大型表的管理。
7. **并行执行**:优化并行执行模式,特别是在大规模并行处理环境中。
8. **安全性和权限管理**:扩展数据库的安全性,提供自定义的身份验证、授权和审计机制。
9. **数据访问接口**:创建新的数据访问接口,以与不同的客户端库或应用程序进行集成。
该文档涵盖了开发、调试、测试和部署数据卡匣的全过程,并包含了许多示例和最佳实践。它还讨论了如何将数据卡匣与Oracle的其他特性,如Materialized Views、Advanced Queuing和Stream等集成。
开发者需要具备扎实的C或C++编程基础,以及对Oracle数据库体系结构和SQL的深入理解,才能充分利用数据卡匣功能。此外,熟悉Oracle的开发接口,如Oracle Call Interface (OCI) 和 Oracle Object-Relational Developer Interface (ORODI),也是必不可少的。
请注意,Oracle数据库的使用和披露受到许可证协议的限制,且受知识产权法律保护。任何未经授权的复制、修改、发布或展示都是被禁止的,除非许可证协议或法律规定明确允许。同时,此文档的内容可能会随时更新,恕不另行通知,且不保证无错误。如果遇到问题,应参考最新的文档或联系Oracle支持获取帮助。
xvi
xvii
List of Examples
3–1 Defining a DataStream data type ............................................................................................. 3-1
3–2 Defining the Type Body ............................................................................................................. 3-2
3–3 Specifying an ODI for an Object Type ..................................................................................... 3-3
3–4 Assigning and Using OIDs........................................................................................................ 3-3
3–5 Creating a Type ........................................................................................................................... 3-4
3–6 Instantiating a Type Object........................................................................................................ 3-4
3–7 Implementing a Member Function........................................................................................... 3-4
3–8 Implementing Functions for Types Without a Simple Id Attributte................................... 3-4
4–1 Defining an Object Type ............................................................................................................ 4-1
4–2 Defining a "Greatest Common Divisor" Function.................................................................. 4-2
4–3 Implementing Methods for an Object Type............................................................................ 4-2
4–4 Invoking Methods; General Syntax.......................................................................................... 4-3
4–5 Invoking Methods; SQL Syntax................................................................................................ 4-3
4–6 Invoking Methods; General Syntax.......................................................................................... 4-3
4–7 Using the SELF Build-In Paramenter....................................................................................... 4-3
4–8 Setting Variable Values .............................................................................................................. 4-3
4–9 Creating a Package Specification.............................................................................................. 4-4
4–10 Asserting the Purity Level of a Type........................................................................................ 4-5
4–11 Asserting the Purity Level of a Package .................................................................................. 4-5
4–12 Asserting a Default Purity Level for All Type Methods and Package Procedures........... 4-5
4–13 Outputing Variable Values to the Terminal, for Debugging................................................ 4-6
4–14 Dropping Packages and Tables................................................................................................. 4-8
4–15 Recompiling Packages................................................................................................................ 4-8
5–1 Creating an Alias Library .......................................................................................................... 5-2
5–2 Specifying the Location of the Library Using an Environment Variable ........................... 5-2
5–3 Defining the Body of a Package................................................................................................ 5-2
5–4 Setting the SID_DESC Entry in the Listener Configuration FIle.......................................... 5-4
5–5
Updating the Network Substrate Configuration to Refer to External Procedures ........... 5-5
5–6 Using Callbacks........................................................................................................................... 5-8
6–1 Creating a CLOB Attribute of a Type ...................................................................................... 6-2
6–2 Creating a LOB Object Table ..................................................................................................... 6-2
6–3 Creating LOB Columns in a Table............................................................................................ 6-2
6–4 Selecting a LOB Locator and Assigning it to a Local Variable............................................. 6-2
6–5 Manipulating LOBs with PUT_LINE() and GETLENGTH()................................................ 6-3
6–6 Syntax of EMPTY_CLOB() and EMPTY_CLOB() Functions ................................................ 6-3
6–7 Using EMPTY_BLOB() with SQL DML................................................................................... 6-4
6–8 Using EMPTY_CLOB() in PL/SQL Programs........................................................................ 6-4
6–9 Selecting a LOB from the Database into a Locator................................................................. 6-6
6–10 Trimming a CLOB....................................................................................................................... 6-8
6–11 Defining a PL/SQL External Procedure.................................................................................. 6-8
6–12 Using Open() and Close() Code Block .................................................................................. 6-10
7–1 Declaring a New Table............................................................................................................... 7-8
7–2 Building a Text Domain Index.................................................................................................. 7-8
7–3 Using the Contains() Operator.................................................................................................. 7-8
8–1 Creating an Indextype................................................................................................................ 8-6
8–2 Dropping an IndexType............................................................................................................. 8-6
8–3 Commenting an INDEXTYPE................................................................................................... 8-7
8–4 Creating a Domain Index........................................................................................................... 8-8
8–5 Changing a Domain Index......................................................................................................... 8-8
8–6 Renaming a Domain Index........................................................................................................ 8-8
8–7 Rebuilding a Domain Index ...................................................................................................... 8-8
8–8 Truncating a Domain Index ...................................................................................................... 8-9
8–9 Dropping a Domain Index......................................................................................................... 8-9
8–10 Getting the Size of a UROWID Column ............................................................................... 8-10
xviii
8–11 Using *_SECONDARY_OBJECTS Views ............................................................................. 8-12
8–12 Using Local Domain Index Methods Within an Indextype............................................... 8-14
8–13 Creating and Partition an Index ............................................................................................ 8-14
8–14 Creating a Local Domain Index ............................................................................................. 8-14
8–15 Dropping a Local Index Partition.......................................................................................... 8-15
8–16 Creating a System-Partitioned Table .................................................................................... 8-17
8–17 Inserting Data into a System-Partitioned Table................................................................... 8-18
8–18 Inserting Data into a System-Partitioned Table Using DATAOBJ_TO_PARTITION ... 8-18
8–19 Inserting Data into a Particular Partition of a Table ........................................................... 8-19
8–20 Splitting an Existing Table Partition ..................................................................................... 8-20
8–21 Calling DML Operations on System-Partitioned Tables.................................................... 8-25
8–22 Querying a System-Partitioned Table................................................................................... 8-25
9–1 Creating an Operator.................................................................................................................. 9-2
9–2 Dropping an Operator; RESTRICT Option ............................................................................. 9-2
9–3 Dropping an Operator; FORCE Option................................................................................... 9-2
9–4 Adding a Binding to an Operator............................................................................................. 9-3
9–5 Adding COMMENTs to an Operator ...................................................................................... 9-3
9–6 Creating the Contains() Operator............................................................................................. 9-4
9–7 Using the Operator Contains() in a Query .............................................................................. 9-4
9–8 An Incorrect Use of the Operator Contains().......................................................................... 9-4
9–9 Operator Predicates .................................................................................................................... 9-5
9–10 Using the Contains() Operator in a Simple Query................................................................. 9-5
9–11 Using the Contains() Operator in a Complex Query............................................................. 9-5
9–12 Using the Contains() Operator in a Multiple Table Query................................................... 9-6
9–13 Invoking Indextype Routines for the Contains() Operator Query ...................................... 9-6
9–14 Using Operators Outside the WHERE Clause........................................................................ 9-7
9–15 Implementing the Contains() Operator in Index-Based Functions ..................................... 9-7
9–16 Binding the Contains() Operator to the Functional Implementation.................................. 9-8
9–17 Accessing Ancillary Data with the Contains() Operator....................................................... 9-9
9–18
Comparing Ancillary Data with the Contains() Operator.................................................... 9-9
9–19 Implementing Bindings for Computations ......................................................................... 9-10
9–20 Evaluating an Ancillary Operator ......................................................................................... 9-10
9–21 Creating an Ancillary Operator Binding .............................................................................. 9-10
10–1 Three Predicate Forms that Trigger a Call to the Optimizer ............................................ 10-3
10–2 Defining a Statistics Type ....................................................................................................... 10-5
10–3 Defining a User-Defined Function ........................................................................................ 10-8
10–4 Calling a Selectivity Function Using Literal Arguments ................................................... 10-8
10–5 Calling a Selectivity Function Using Non-Literal Arguments .......................................... 10-8
10–6 Calling a Cost Function Using Literal Arguments.............................................................. 10-9
10–7 Calling a Cost Function Using Non-Literal Arguments .................................................... 10-9
10–8 Defining an Operator ............................................................................................................ 10-10
10–9 Calling an Index Cost Function Using Non-Literal Arguments..................................... 10-10
10–10 Creating a Table with an Object Type Column ................................................................. 10-12
10–11 Associating Statistics with Columns for User-Defined Statistics.................................... 10-12
10–12 Associating Statistics with Data Types for User-Defined Statistics................................ 10-12
10–13 Creating an Indextype, an Index and an Operator for User-Defined Statistics............ 10-13
10–14 Associating Statistics with System-Managed Indextypes................................................ 10-13
10–15 Associating Statistics with User-Defined Operators......................................................... 10-14
10–16 Associating Statistics with Standalone Functions............................................................. 10-14
10–17 Associating Statistics with Package Functions .................................................................. 10-14
10–18 Associating Statistics with Type Methods.......................................................................... 10-14
10–19 Associating Statistics with Default Selectivity................................................................... 10-14
10–20 Associating Statistics with User-Defined Operators......................................................... 10-15
10–21 Associating Statistics with Standalone Functions............................................................. 10-15
10–22 Associating Statistics with Package Functions .................................................................. 10-16
xix
10–23 Associating Statistics with Type Methods.......................................................................... 10-16
10–24 Associating Statistics with Default Cost............................................................................. 10-16
10–25 Declaring NULL Statistics Associations for Columns and Indexes ............................... 10-16
11–1 How User-Defined Aggregate Functions Work.................................................................. 11-2
11–2 Implementing the ODCIAggregate Interface ...................................................................... 11-3
11–3 Defining a User-Defined Aggregate Function..................................................................... 11-3
11–4 Using the SELECT Statement with User-Defined Aggregate Functions ......................... 11-3
11–5 Using the HAVING Clause with User-Defined Aggregate Functions ............................ 11-3
11–6 Using other Query Options with User-Defined Aggregate Functions ............................ 11-4
11–7 Parallel-Enabling a User-Defined Aggregate Function...................................................... 11-4
11–8 Using External Memory to Store Aggregate Context......................................................... 11-5
11–9 Using User-Defined Aggregates as Analytic Functions..................................................... 11-6
11–10 Creating Materialized Views.................................................................................................. 11-7
11–11 Enabling Materialized Views for Query Rewrite................................................................ 11-7
11–12 Creating and Using a User-Defined Aggregate Function.................................................. 11-8
12–1 Initializing OCI Handles......................................................................................................... 12-3
12–2 Retrieving Error Information Using OCIErrorGet() ........................................................... 12-3
13–1 Creating a Collection Type ..................................................................................................... 13-2
13–2 Storing a Clob in a Table......................................................................................................... 13-3
13–3 Creating a Function that Returns a Collection Type........................................................... 13-3
13–4 Using a Collection Type in a Query ...................................................................................... 13-3
13–5 Declaring a Pipelined Table Function with REF CURSOR Arguments........................... 13-4
13–6 Using a Pipelined Table Function with REF CURSOR Arguments ................................. 13-4
13–7 Declaring Pipelined Table Functions for the Interface Approach .................................... 13-6
13–8 Declaring Pipelined Table Functions for the Native PL/SQL Approach........................ 13-6
13–9 Implementing a Pipelined Table Function for the Native PL/SQL Approach............... 13-6
13–10 Pipelining Function Results from One Function to Another............................................. 13-7
13–11 Querying for AnyType Data ................................................................................................ 13-10
13–12
Implementing the ODCITableDescribe() Method............................................................. 13-10
13–13 Using Functions that Return AnyType............................................................................... 13-11
13–14 Building an Array of Attribute Positions and Save it in a Scan Context ....................... 13-11
13–15 Using a Table Function to Iteratively Retrieve Rows ....................................................... 13-12
13–16 Using Multiple Invokations of a Table Function............................................................... 13-12
13–17 Defining REF CURSOR Variables for Table Function Queries ....................................... 13-12
13–18 Using a REF CURSOR Variable ........................................................................................... 13-13
13–19 Using a REF CURSOR Variable More Effectively............................................................. 13-13
13–20 Declaring a Table Function with Autonomous Transaction Pragma............................. 13-13
13–21 Creating a View over a Table ............................................................................................... 13-13
13–22 How an INSTEAD OF Trigger is Fired when a Row is Inserted into a View............... 13-13
13–23 Passing a Set of Rows to a PL/SQL Function in a REF CURSOR................................... 13-14
13–24 Directly Passing Results from a Subquery to a Function................................................. 13-14
13–25 Passing a Set of Rows to a PL/SQL Function Through REF CURSOR.......................... 13-15
13–26 Invoking a Function that Uses Several REF CURSOR Parameters................................. 13-15
13–27 Using REF CURSOR to Pass Return Values Between Table Functions ......................... 13-15
13–28 Explicitly Using a Query REF CURSOR as Table Function Parameter.......................... 13-15
13–29 Using a REF CURSOR in a Callout...................................................................................... 13-15
13–30 Specifying Data Partitioning for a REF CURSOR Parameter .......................................... 13-17
13–31 Implementing the StockPivot() Function ........................................................................... 13-17
13–32 Using a REF CURSOR to Generate a Table from Another Table.................................... 13-17
13–33 Using a REF CURSOR to Scan and Insert .......................................................................... 13-18
13–34 Using a REF CURSOR to Read a Set of External FIles...................................................... 13-18
13–35 Controlling Input Data Streaming....................................................................................... 13-19
13–36 Ordering the Input Stream ................................................................................................... 13-19
13–37 Loading a Domain Index in Parallel ................................................................................... 13-20
13–38 Merging the Results from Parallel Domain Index Loads................................................. 13-21
xx
13–39 Invoking the Merging of Parallel Domain Index Loads................................................... 13-21
15–1 Creating a Database User for the Power Demand Cartridge .......................................... 15-13
15–2 Creating PowerGrid_Typ and NumTab_Typ Types for Power Demand Cartridge... 15-13
15–3 Creating PowerDemand_Typ Type for Power Demand Cartridge ............................... 15-13
15–4 Implementing PowerDemand_Typ Type for Power Demand Cartridge...................... 15-14
15–5 Implementing Power_XXX_Func() Functions for Power Demand Cartridge .............. 15-16
15–6 Implementing Power_XXX() Functions for Power Demand Cartridge......................... 15-18
15–7 Creating power_idxtype_im Object Type for Power Demand Cartridge ..................... 15-19
15–8 Registering Interface and Index Functions in Power Demand Cartridge ..................... 15-20
15–9 Registering ODCIIndexCreate() for Power Demand Cartridge...................................... 15-20
15–10 Registering ODCIIndexDrop() for Power Demand Cartridge........................................ 15-22
15–11 Registering ODCIIndexStart() for Power Demand Cartridge......................................... 15-23
15–12 Registering ODCIIndexStart() for Any Queries for Power Demand Cartridge ........... 15-24
15–13 Registering ODCIIndexFetch() for Power Demand Cartridge........................................ 15-26
15–14 Registering ODCIIndexStart() for Power Demand Cartridge......................................... 15-27
15–15 Registering ODCIIndexInsert() for Power Demand Cartridge....................................... 15-27
15–16 Registering ODCIIndexDelete() for Power Demand Cartridge...................................... 15-28
15–17 Registering ODCIIndexUpdate() for Power Demand Cartridge .................................... 15-29
15–18 Registering ODCIIndexGetMetadata() for Power Demand Cartridge .......................... 15-30
15–19 Creating Package power_pkg for the Power Demand Cartridge................................... 15-30
15–20 Creating Indextype power_idxtype for Power Demand Cartridge ............................... 15-32
15–21 Creating Statistics Table PowerCartUserStats for Power Demand Cartridge .............. 15-32
15–22 Creating power_statistics Object Type Definition for Power Demand Cartridge ....... 15-33
15–23 Registering interfaces and Statistics Functions for Power Demand Cartridge............. 15-35
15–24 Registering ODCIStatsCollect() for Power Demand Cartridge.......................................
15-35
15–25 Registering ODCIStatsDelete() for Power Demand Cartridge........................................ 15-37
15–26 Registering ODCIStatsCollect() for Power Demand Cartridge....................................... 15-38
15–27 Registering ODCIStatsDelete() for Domain Indexes in Power Demand Cartridge ..... 15-39
15–28 Implementing Selectivity Function for Power Demand Cartridge ................................ 15-40
15–29 Registering ODCIStatsSelectivity() for Queries for Power Demand Cartridge............ 15-42
15–30 Registering ODCISIndexCost() for Queries for Power Demand Cartridge .................. 15-45
15–31 Registering ODCIStatsIndexCost() for Any Queries for Power Demand Cartridge ... 15-46
15–32 Registering ODCIStatsFunctionCost() for Power Demand Cartridge ........................... 15-47
15–33 Using Statistics Methods with Database Objects for Power Demand Cartridge.......... 15-48
15–34 Analyzing Database Objects for the Power Demand Cartridge ..................................... 15-48
15–35 Creating PowerDemand_Tab Table for Power Demand Cartridge............................... 15-49
15–36 Populating PowerDemand_Tab Table for Power Demand Cartridge........................... 15-50
15–37 Computing Grid and Cell Demands for Power Demand Cartridge .............................. 15-50
15–38 Making Equality Queries for Power Demand Cartridge ................................................. 15-51
15–39 Creating an Index in PowerDemand_Tab Table for Power Demand Cartridge .......... 15-52
15–40 Making Equality Queries with Index for Power Demand Cartridge............................. 15-52
16–1 Implementing the EQUALS Operator .................................................................................. 16-2
16–2 Implementing the LESS THAN Operator ............................................................................ 16-2
16–3 Implementing the GREATER THAN Operator................................................................... 16-2
16–4 Creating the EQUALS Operator ............................................................................................ 16-3
16–5 Creating the LESS THAN Operator ...................................................................................... 16-3
16–6 Creating the GREATER THAN Operator ............................................................................ 16-3
16–7 Creating a PSBTREE Index Type ........................................................................................... 16-3
16–8 Creating the Implementation Body for PBSTREE............................................................... 16-4
16–9 Implementing ODCIGetInterfaces() for PBSTREE in PL/SQL ......................................... 16-4
16–10 Implementing ODCIIndexCreate() for PBSTREE in PL/SQL ........................................... 16-4
16–11 Implementing ODCIIndexDrop() for PBSTREE in PL/SQL ............................................. 16-5
16–12 Implementing ODCIIndexAlter() for PSBTREE in PL/SQL.............................................. 16-6
16–13 Implementing ODCIIndexUpdPartMetadata() for PSBTREE in PL/SQL....................... 16-7
16–14 Implementing ODCIIndexExchangePartition() for PSBTREE in PL/SQL...................... 16-7
剩余369页未读,继续阅读
2023-06-18 上传
2018-02-12 上传
2023-06-18 上传
2023-04-07 上传
2023-06-18 上传
2023-04-06 上传
2021-04-22 上传
2021-04-29 上传
2013-07-31 上传
weixin_40191861_zj
- 粉丝: 84
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 深入浅出:自定义 Grunt 任务的实践指南
- 网络物理突变工具的多点路径规划实现与分析
- multifeed: 实现多作者间的超核心共享与同步技术
- C++商品交易系统实习项目详细要求
- macOS系统Python模块whl包安装教程
- 掌握fullstackJS:构建React框架与快速开发应用
- React-Purify: 实现React组件纯净方法的工具介绍
- deck.js:构建现代HTML演示的JavaScript库
- nunn:现代C++17实现的机器学习库开源项目
- Python安装包 Acquisition-4.12-cp35-cp35m-win_amd64.whl.zip 使用说明
- Amaranthus-tuberculatus基因组分析脚本集
- Ubuntu 12.04下Realtek RTL8821AE驱动的向后移植指南
- 掌握Jest环境下的最新jsdom功能
- CAGI Toolkit:开源Asterisk PBX的AGI应用开发
- MyDropDemo: 体验QGraphicsView的拖放功能
- 远程FPGA平台上的Quartus II17.1 LCD色块闪烁现象解析
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功