Oracle学习(5)--存储过程、索引、同义词

来源:互联网 发布:退款师软件 编辑:程序博客网 时间:2024/06/06 08:59

1 创建存储过程

例:创建一个根据员工号删除员工信息的存储过程

create or replace procedure delempno(empid in number) is    ----创建或替换存储过程,参数为empid,参数类型为empid

begin

    delete from emp where empno=empid;

    commit;

end delempno;

 

2 如何在pl/sql developer中执行存储过程

在pl/sql developer的菜单栏中选择 文件→新建→命令窗口,将会弹出一个命令窗口,

在命令窗口中输入  execute delempno(7566); 

7566为员工号,系统会提示存储过程执行完成。

 

3 创建索引

create index index_test_id on test_index(id);

 4 同义词(Synonym)

同义词是现有对象的一个别名分为私有同义词和公共同义词;

例:给scott用户赋予创建同义词的权限

grant create any synonym to scott;

例:创建scott用户下的salgrade表的同义词,名称为sg

create synonym sg for scott.salgrade;

例:创建公共同义词

create public synonym emp for scott.emp;