--建立物件型別
create or replace type emp_typ as object (
id number,
name varchar2(30),
sal number,
comm number,
member procedure change_comm(new_comm number),
member function get_info return varchar2
) ;--建立物件型別建構函式定義
create or replace type body emp_typ is
member procedure change_comm(new_comm number)
is begin
comm:=new_comm;
end;
member function get_info return varchar2
isv_info varchar2(30);
begin
v_info:='姓名:'||name ||' 工資:'||sal;
return v_info;
end;
end;
--建立帶型別的表
create table detail (empt emp_typ,tel number,addr varchar2(20))
--插入資料
insert into detail values (emp_typ(6666,'yangliping',5000,3000),13675047974,'shanghai caobao')
--更新資料
update detail set empt=emp_typ(7777,'yangliing',3000,2000) where tel=13675047974
--查詢資料
select * from detail
結果:empt.id empt.name empt.sal empt.comm tel addr
6666 yangliing 8000 5000 13833338888 北京
7777 yangliing 3000 2000 13675047974 shanghai caobao
--刪除物件表資料
delete from detail where tel=13675047974
ORACLE的物件操作
建立物件型別 create type object type as object column name type,column name type,member function fun name return type member procedure proc name 其中member fu...
物件導向 物件的使用
在程式設計中先定義類,才能宣告類的物件。class oldboystudent school oldboy 語法 在類名後加括號,與呼叫函式寫法相同。s1 oldboystudent 查print s1.school oldboy 增s1.age 1 print s1.age print s1.di...
Oracle其他物件
b 檢視 b b 建立檢視 b create or replace view as b 序列 b b 建立序列 b create sequence increment by n start with n maxvalue n minvalue n cycle nocycle cache n noca...