一.oracle自定义函数 1.不带参数的函数: 返回t_book表的总条数: SQL> create function getBookCount return number as begin declare book_count number; begin select count(*) into book_count from t_book; return book_count; end; end getBookCount; / 函数已创建. //sys dba给当前用户授权创建函数.创建存…
Oracle触发器 一.触发器简介 具备某些条件,由数据库自动执行的一些DML操作行为: 二.语句触发器 现在数据库创建t_book表:t_booktype表:t_book表的typeid存在外键参考t_booktype的id: 1.需求:当前用户不是CC时,insert/delete/update t_book表就提示‘权限不足’: SQL> create or replace trigger tr_book before insert or update or delete on t_boo…
一.if条件语句 set serverout on; ; v ):='world'; begin dbms_output.put_line('hello'||n||v); end; / hello1world declare emp_count number; begin ; ) then dbms_output.put_line('有'||emp_count||'员工的基本薪资大于等于3000'); else dbms_output.put_line('没有员工的基本薪资大于等于3000');…
沿用 Oracle OCI操作UDT相关学习 一文中定义的类型和表. 1.更改数据 在sqldeveloper 中更新数据, update dxl.cust set addr.street='a11' where addr.street ='aaa';commit; 上边这个语句会报错,而如果采用下边这个语句操作则正确update dxl.cust a set a.addr.street='a11' where a.addr.street ='aaa';commit; 2.OCI 更改数据 同样…