oracle期末总结

登录

设置

set pagesize 0; //输出每页行数,缺省为24,为了避免分页,可设定为0。

set linesize 80; //输出一行字符个数,缺省为80

查看表结构

DESCRIBE <表名>;

或简写

DESC <表名>;

执行sql文件的指令

start 或 @
如果sql文件在当前目录下,可以直接执行:

@demo.sql

如果sql文件不在当前目录下,可以使用绝对路径:

@D:/demo.sql

用户、角色权限

在sys模式下授予Scott用户创建用户和角色的权利

grant create user,create role to scott;

查询

查询部门号30中所有职员的部门号、姓名、工资总和(工资+佣金)

select deptno,ename,sal+nvl(comm,0) total from emp where deptno=30;

创建表空间 实验二

实验四

存储过程

1.无参数

创建存储过程proc_execution实现把员工号7369的员工姓名改成自己姓名。

create or repalce procedure proc_execution
is
begin
	update emp set ename='jahui'
	where empno=7369;
end proc_execution;
2.带输入参数

解雇给定职工号的职工,并调用proc_execution:

create or replace procedure fire_emp
(v_emp_no in emp.empno%type)
is 
begin
	proc_execution;
	delete from emp where empno=v_emp_no;
end fire_emp

3.带输入输出参数

查询EMP中给定职工号的姓名、工资和佣金。

create or replace procedure query_emp
(v_emp_no in emp.empno%type,
v_emp_name out emp.ename%type,
v_emp_sal out emp.sal%type,
v_emp_comm out emp.comm%type)
is
begin
	select ename,sal,comm
	into v_emp_name,v_emp_sal,v_emp_comm
	from emp where empno=v_emp_no;
end query_emp;

execute fire_emp(7654);

其他

创建存储过程,实现功能为:删除scott.emp表中任意给定职工号的职工记录;

create or replace procedure delete_emp
is
begin
	delete from dept where deptno=id;
end delete_emp;

触发器

游标

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值