`
hekui1016
  • 浏览: 51269 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

COLUMN_VALUE Pseudocolumn

 
阅读更多

在使用Oracle Table()函数时遇到问题,查找资料得知Pseudocolumn

资料地址为:

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns004.htm

 

 

COLUMN_VALUE Pseudocolumn

 

When you refer to an XMLTable construct without the COLUMNS clause, or when you use the TABLE function to refer to a scalar nested table type, the database returns a virtual table with a single column. This name of this pseudocolumn is COLUMN_VALUE.

In the context of XMLTable, the value returned is of datatype XMLType. For example, the following two statements are equivalent, and the output for both shows COLUMN_VALUEas the name of the column being returned:

SELECT * FROM XMLTABLE('<a>123</a>');

COLUMN_VALUE
---------------------------------------
<a>123</a>

SELECT COLUMN_VALUE FROM (XMLTable('<a>123</a>'));

COLUMN_VALUE
----------------------------------------
<a>123</a>

In the context of a TABLE function, the value returned is the datatype of the collection element. The following statements create the two levels of nested tables illustrated in"Multi-level Collection Example" to show the uses of COLUMN_VALUE in this context:

CREATE TYPE phone AS TABLE OF NUMBER;   
/
CREATE TYPE phone_list AS TABLE OF phone;
/

The next statement uses COLUMN_VALUE to select from the phone type:

SELECT t.COLUMN_VALUE from table(phone(1,2,3)) t;

COLUMN_VALUE
------------
          1
          2
          3

In a nested type, you can use the COLUMN_VALUE pseudocolumn in both the select list and the TABLE function:

SELECT t.COLUMN_VALUE FROM 
   TABLE(phone_list(phone(1,2,3))) p, TABLE(p.COLUMN_VALUE) t;
COLUMN_VALUE
------------
           1
           2
           3

The keyword COLUMN_VALUE is also the name that Oracle Database generates for the scalar value of an inner nested table without a column or attribute name, as shown in the example that follows. In this context, COLUMN_VALUE is not a pseudocolumn, but an actual column name.

CREATE TABLE my_customers (
   cust_id       NUMBER,
   name          VARCHAR2(25),
   phone_numbers phone_list,
   credit_limit  NUMBER)
   NESTED TABLE phone_numbers STORE AS outer_ntab
   (NESTED TABLE COLUMN_VALUE STORE AS inner_ntab);

See Also:

 

 

分享到:
评论

相关推荐

    Oracle8i_9i数据库基础

    第一部分 Oracle SQL*PLUS基础 23 第一章 Oracle数据库基础 23 §1.1 理解关系数据库系统(RDBMS) 23 §1.1.1 关系模型 23 §1.1.2 Codd十二法则 24 §1.2 关系数据库系统(RDBMS)的组成 24 §1.2.1 RDBMS 内核 24...

    oracle advanced sql 高级SQL教程 ORACLE官方教材

    Ranking Rows with the LEVEL Pseudocolumn 5-10 Formatting Hierarchical Reports Using LEVEL and LPAD 5-11 Pruning Branches 5-13 Summary 5-14 Practice 5 Overview 5-15 6 Oracle9i Extensions to DML and DDL...

    oracle的伪列与分页

    在Oracle数据库中,伪列(Pseudocolumn)并非真正意义上的列,而是一种特殊的数据库对象,它看起来像表中的一个列,但实际上并不存储数据。Oracle提供了一些内置的伪列供用户使用,如`ROWID`和`ROWNUM`等,这些伪列...

    数据结构伪代码

    其中,**伪列(Pseudocolumn)**和**伪表**是两个重要的特性。 ##### 1. Oracle伪列 **伪列**是指Oracle系统为了实现完整的关系数据库功能而提供的特殊列,这些列不是在创建表时由用户定义的,而是由Oracle系统自动...

    oracle实用教程

    伪列(Pseudocolumn)并不是真正的列,而是Oracle数据库中的一种特殊概念,用于获取某些信息。常用的伪列包括: - **ROWID**:表示行的唯一标识。 - **ROWNUM**:返回行号。 **Oracle函数** Oracle提供了大量的...

Global site tag (gtag.js) - Google Analytics