<div id="codeSnippetWrapper"> <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',courier,monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New',monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px">------------------------抽象数据类型---------<span style="color: #008000">--
replace type address (
final; -- final表示该类型可以有子类型
address说明这个类型继承至address类型
replace type detailAddress address (
empInfo
empInfo (
(2),--性别
,--年龄
empInfo (,,28,detailAddress(,,));
empInfo (,26,,));
empInfo (,,29,));
* empInfo;
* empInfo eSex = ;
* empInfo e e.eAddress.city = ; --如果查询条件包含属性必须用表的别名
empInfo e e.eAddress = detailAddress(,) e.eName = ;
empInfo e e.eAddress.city = e.eName = ;
empInfo e e.eAddress.city = ;
idxemp empInfo(eAddress.city);
empInfo;
type address force; --强制删除抽象类型
replace type person (
(2),--性别
--年龄
final;
replace type student person (
stuInfo student;
stuInfo pk_stuInfo (stuId);
stuInfo (,1001);
stuInfo (student(,1002));
stuInfo (student(,1003));
* stuInfo stuId = 1002;
stuInfo pAge = 29 pName = ;
stuInfo stuId = 1001;
;
(表别名)函数用来返回对象的OID,也就是对象标识符,对象表也有rowid
(s) stuInfo s;
rowid,(s) OIDS stuInfo s;
stuScore (
student,--stu这一列的值必须出现在stuInfo表中,且stu这一列存的对象的OID而不是对象本身
--分数
stuscore ( (s) stuInfo stuId = 1001,90)
stuscore (s),90 stuInfo s stuId = 1001;
stuInfo s; --插入3行数据
stuInfo s stuId = 1003;
* stuScore;
(列名)函数可以把OID还原为对象,主键列显示有问题
(s.stu),score stuScore s s.stu.stuId = 1001;
stuScore score=100 stu = ( (s) stuInfo s stuId = 1001);
stuScore s score = 99 s.stu.stuId = 1001;
stuScore stu = ( (s) stuInfo s stuId = 1001);
stuScore s s.stu.stuId = 1001;
stuScore stuId = 1001;
aaa
);
type aaaa
replace view_stu aaaa oid(a)
* aaa;
* view_stu;
get_pro varchar2,--函数,后面接,而不是;
get_city varchar2,
set_pro(pro varchar2),--过程
set_city(cy varchar2)
replace type body ADDRESS--后面不能加
--后面不能加begin
get_pro varchar2
province;
get_pro;
get_city varchar2
city;
;
set_pro(pro varchar2)
set_city(cy varchar2)
;
;
,);
stuInfo;
stuInfo (
,monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px"> addr address
);
stuInfo (1,addr);
);
);
stuInfo (2,addr);
* stuInfo;
type address force;
replace type arrType varray(10) number(4);
replace type scoreType (
replace type arrScoreType varray(10) scoreType;
stuInfo (1,arrScoreType(
,50),scoreType(,80),scoreType(,90)));
stuInfo (2,60),85),95),scoreType(,60)));
stuInfo (3,70),93)));
* stuInfo; --查询结果是集合
* ( s.score stuInfo s s.stuId = 2);
s.stuId,t.* stuInfo s,monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px"> ( score stuInfo stuId = s.stuId) t
s.stuId = 2;
stuInfo score = arrScoreType(
stuId = 1;
type arrScoreType force;
stuInfo;
replace type scoreType (
replace type nestTable scoreType;
,monospace; direction: ltr; border-top-style: none; color: black; font-size: 10pt; border-left-style: none; overflow: visible; padding-top: 0px"> score nestTable --其实存的是引用,实际数据存在abc表中
score store abc;
score store abc意思是:stuInfo这个表中的score这一列是嵌套表类型,嵌套表实际是存在abc这个表中
* ( ss.score stuInfo ss stuId = 3);
( ss.score stuInfo ss stuId = s.stuId) t
s.stuId = 3;
( ss.score stuInfo ss stuId=3) t
t.score = 80 t.subName = ;
( ss.score stuInfo ss stuId = 3) t
t.subname=;
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|