PL/SQL_1

1.字段索引

   create index 索引名 on 表名(索引字段名)                 --创建索引

   create unique index 索引名 on 表名(索引字段名)     --创建唯一索引

   drop index 索引名 on 表名                                         --删除索引

 

2.存储过程

   create procedure 存储名(参数) is

   begin

     执行部分

   end

 

3.函数(一般只返回一个值)

   create function xxx(xxx) return number is yearSal number(7,2);

   begin

     select xxx into yearSal from xxx where xxx=xxx;

     return yearSal;

   end;

 

4.包

   create or replace package body  xxx is

       xxxprocedure

       xxxfunction

   end;

 

5.要定义和数据库字段相同类型的参数

    xxx表.xxx字段%type

 

6.复合类型-->记录实例

 

--定义一个pl/sql记录实例,内部有3个元素
declare
type emp_record_type is record(name number(10),salary number(10,2),title varchar2(30))

--定义一个emp_record_type变量
sp_record emp_record_type;

begin
--把3个字段取出来放到记录类型中
select name,salary,title into sp_record  from xxx where xxx

--使用时,用"."就可以引用到了
dbms_output.put_line(emp_record_type.name)

 

7.复合类型-->表实例

  

--定义一个pl/sql表实例,下标是整数
declare
type emp_table_type is table of xxx表.xxx字段%type index by binary_integer;

--定义一个emp_table_type变量
sp_table emp_table_type;

begin
--把3个字段取出来放到记录类型中
select name into sp_table(0) from xxx where xxx

--使用
dbms_output.put_line(sp_table(0))

 8.触发器

create [or replace] trigger 触发器名 触发时间 触发事件

on 表名

[for each row]

pl/sql 语句

  

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值