问题描述:
有一群人数据集,不是教练就是运动员. 教练和运动员的统一属性是姓名,出生年月,年纪
教练有自己的属性是角色
运动员也有自己的属性是身高和体重
现要设计一张表结构, 年纪自动由出生年月算出(但不能用trigger),教练和运动员的区分要用subtype.








































































































VALUE
Syntax
Description of the illustration value.gif
Purpose
VALUE
takes as its argument a correlation variable (table alias) associated with a row of an object table and returns object instances stored in the object table. The type of the object instances is the same type as the object table.
IS OF type Condition
Use the IS
OF
type
condition to test object instances based on their specific type information.
is_of_type_conditions::=
Description of the illustration is_of_type_conditions.gif
You must have EXECUTE
privilege on all types referenced by type
, and all type
s must belong to the same type family.
This condition evaluates to null if expr
is null. If expr
is not null, then the condition evaluates to true (or false if you specify the NOT
keyword) under either of these circumstances:
-
The most specific type of
expr
is the subtype of one of the types specified in thetype
list and you have not specifiedONLY
for the type, or -
The most specific type of
expr
is explicitly specified in thetype
list.
The expr
frequently takes the form of the VALUE
function with a correlation variable.
The following example uses the sample table oe.persons
, which is built on a type hierarchy in "Substitutable Table and Column Examples". The example uses the IS
OF
type
condition to restrict the query to specific subtypes:
TREAT
Syntax
Description of the illustration treat.gif
Purpose
TREAT
changes the declared type of an expression.
You must have the EXECUTE
object privilege on type
to use this function.
-
type
must be some supertype or subtype of the declared type ofexpr
. If the most specific type ofexpr
istype
(or some subtype oftype
), thenTREAT
returnsexpr
. If the most specific type ofexpr
is nottype
(or some subtype oftype
), thenTREAT
returnsNULL
. -
You can specify
REF
only if the declared type ofexpr
is aREF
type. -
If the declared type of
expr
is aREF
to a source type ofexpr
, thentype
must be some subtype or supertype of the source type ofexpr
. If the most specific type ofDEREF
(expr
) istype
(or a subtype oftype
), thenTREAT
returnsexpr
. If the most specific type ofDEREF
(expr
) is nottype
(or a subtype oftype
), thenTREAT
returnsNULL
.
This function does not support CLOB
data directly. However, CLOB
s can be passed in as arguments through implicit data conversion.
讨论见:http://www.itpub.net/showthread.php?s=&threadid=322109&perpage=10&pagenumber=1