对象标识符和对象引用+对象标识符+对象引用+为对象引用插入数据+查询对象引用OID对应的实际值+更新对象引用+删除对象引用
来源:互联网 发布:双录取很坑人 知乎 编辑:程序博客网 时间:2024/06/05 02:41
对象标识符和对象引用
测试数据
--创建对象类型class3--创建对象类型头create or replace type class3 as object (id number,name varchar2 ( 20 ),member function get_name(no varchar2) return varchar2) ;--创建对象体create or replace type body class3 as member function get_name(no varchar2) return varchar2 as name varchar2(20); beginselect sname into name from zhou.student where sno=no ; return name; end;end;--创建对象类型studentfar,里面有列对象class3create or replace type studentfar as object (sid number,sname varchar2 ( 20 ),class class3) ;--创建对象表create table studentson of studentfar;--插入数据insert into studentson values(11,'丽丽',class3(1101,'语文'));insert into studentson values(11,'丽丽',class3(1102,'数学'));
对象标识符(OID)
1对象表中的每一个对象都有唯一的对象标识符(Object identifier,OID)
2OID存储在名称为ref的列中
3OID表示数据库中对象的位置,可以将OID存储在对象引用中,通过他就可以访问它引用的对象
举例
select ref(s) from studentson s where s.class.id=1101;
ref(s)的值就是OID。
对象引用
1对象引用使用ref类型进行定义,通常用作指向对象表中对象的指针
2对象引用可以为对象表之间的关系建立模型,而不是使用外键。
语法
create table tabe_name(
ref_name ref type_name scope is table_type_name
);
scope is:将对象引用限制在特定表中的对象上
举例
create table school(id number,class_ref ref studentfar scope is studentson);
为对象引用插入数据
insert into school values(1,(select ref(s) from studentson s where s.class.id=1101));select * from school;select class_ref from school;
查询对象引用OID对应的实际值
select id,deref(class_ref) from school;select id,deref(class_ref).sid,deref(class_ref).sname,deref(class_ref).class.id,deref(class_ref).class.name from school;
更新对象引用
update school set class_ref=((select ref(s) from studentson s where s.class.id=1102))where id=1;select id,deref(class_ref).sid,deref(class_ref).sname,deref(class_ref).class.id,deref(class_ref).class.name from school;
删除对象引用
delete school where id=1;select id,deref(class_ref).sid,deref(class_ref).sname,deref(class_ref).class.id,deref(class_ref).class.name from school;
阅读全文
0 0
- 对象标识符和对象引用+对象标识符+对象引用+为对象引用插入数据+查询对象引用OID对应的实际值+更新对象引用+删除对象引用
- 对象和对象引用
- 对象和对象引用
- 对象和对象引用
- 对象引用
- 对象引用
- 对象引用
- 对象引用
- 引用/对象
- 对象引用
- 对象引用
- 对象引用
- 对象引用
- 对象和对象的引用
- 将对象改为引用对象 值对象和引用对象
- 对象与对象引用
- 对象与对象引用
- 对象、对象引用、实例
- 呼吸灯 串口 SGM3146
- LeetCode 40. Combination Sum II
- 正则表达式
- 如何进行CRC校验
- 341. Flatten Nested List Iterator
- 对象标识符和对象引用+对象标识符+对象引用+为对象引用插入数据+查询对象引用OID对应的实际值+更新对象引用+删除对象引用
- BIEE 11g 使用叙述视图实现复杂中国式表格一例
- USACO-Section1.2 dualpal[字符处理]
- IOS基础控件 UIImageView swift3.1
- Pascal中repeat的用法
- Java变量
- Elastic Ball in the Frame(水题)
- 深入浅出理解视频编码H264结构
- Q21_按之字形顺序打印二叉树