What is a subobject for a type?
In all_objects
theres a a column called SUBOBJECT_NAME
, and the docs say that this is:
Name of the subobject (for example, partition)
If you do the following query:
select *
from all_objects
where owner = 'MDSYS'
and object_name = 'SDO_TGL_OB开发者_运维技巧JECT_ARRAY'
You find that MDSYS.SDO_TGL_OBJECT_ARRAY
has a subobject called $VNS_1
. What is it? How can types have subobjects?
Sometimes the documentation means exactly what it says.
By way of illustration, I have a table called RANGE_PART_INTERVAL_TABLE
which has three partitions. I run the pertinent query against ALL_OBJECTS, and lo!
SQL> select object_name, object_type, subobject_name
2 from all_objects
3 where object_name = 'RANGE_PART_INTERVAL_TABLE'
4 /
OBJECT_NAME OBJECT_TYPE SUBOBJECT_NAME
------------------------------ ------------------- ---------------
RANGE_PART_INTERVAL_TABLE TABLE
RANGE_PART_INTERVAL_TABLE TABLE PARTITION SYS_P60
RANGE_PART_INTERVAL_TABLE TABLE PARTITION SYS_P61
RANGE_PART_INTERVAL_TABLE TABLE PARTITION SYS_P62
SQL>
I think the problem is the use of the word "objects". Oracle comes from a time before Object-Oriented Programming (if you can imagine such a thing). Its data dictionary uses "database object" to mean "thing" - table, view, sequence, procedure, etc. When Oracle introduced OOP into the database it used the keyword TYPE
.for these new things. So the view ALL_OBJECTS is a list of all the things your schema has privileges on, not just the user-defined types.
edit
Just to be clear, this has nothing to do with type inheritence.
SQL> create type my_type as object (attr1 number) not final
2 /
Type created.
SQL> create type my_sub_1 under my_type (attr2 date)
2 /
Type created.
SQL> select object_name, object_type, subobject_name
2 from all_objects
3 where object_name = 'MY_TYPE'
4 /
OBJECT_NAME OBJECT_TYPE SUBOBJECT_NAME
------------------------------ ------------------- ---------------
MY_TYPE TYPE
SQL>
Inheritence is shown by the USER/ALL/DBA_TYPES view, which shows the supertype of the derived type:...
SQL> select type_name, supertype_name
2 from all_types
3 where type_name in ('MY_TYPE', 'MY_SUB_1')
4 /
TYPE_NAME SUPERTYPE_NAME
------------------------------ ------------------------------
MY_SUB_1 MY_TYPE
MY_TYPE
SQL>
edit2
TheCoop points out:
types can't have partitions
In the specific case they cites $VNS_1
is an artefact of Type Evolution. When we execute an ALTER TYPE after that Type has been in use Oracle creates a version of it. We can see this in the %_TYPE_VERSIONS views....
SQL> select * from dba_type_versions
2 where owner = 'MDSYS'
3 and type_name = 'SDO_TGL_OBJECT_ARRAY'
4 /
OWNER TYPE_NAME VERSION#
------------------------------ ------------------------------ ----------
TYPECODE STATUS LINE
------------------------------ ------- ----------
TEXT
------------------------------------------------------------------------------
HASHCODE
----------------------------------
MDSYS SDO_TGL_OBJECT_ARRAY 1
COLLECTION VALID 1
type SDO_TGL_OBJECT_ARRAY
61EB9AEC10198F71C141D13B32F52C00A8
MDSYS SDO_TGL_OBJECT_ARRAY 1
COLLECTION VALID 2
as VARRAY (1000000) of SDO_TGL_OBJECT
61EB9AEC10198F71C141D13B32F52C00A8
MDSYS SDO_TGL_OBJECT_ARRAY 2
COLLECTION VALID 1
type SDO_TGL_OBJECT_ARRAY
6184209BAEF1F731B937760C2BA8B45688
MDSYS SDO_TGL_OBJECT_ARRAY 2
COLLECTION VALID 2
as VARRAY (1000000) of SDO_TGL_OBJECT
6184209BAEF1F731B937760C2BA8B45688
MDSYS SDO_TGL_OBJECT_ARRAY 2
COLLECTION VALID 3
alter type SDO_TGL_OBJECT_ARRAY modify limit 10000000 cascade
6184209BAEF1F731B937760C2BA8B45688
SQL>
Find out more.
精彩评论