PLSQL语句:

PLSQL语句:,第1张

写一个简单的存储过程就可以了

前面的就省略了.

select salary into tmp_salary from employees where id>=200

if tmp_salary<5000 then

insert into special_sal (id,salary)

select id,salary from employees where id>=200 and salary <5000

insert into SAL_HISTORY (id,hire_day,salary)

select id,hire_day,salary from employees where id>=200 and salary <5000

insert into MGR_HISTORY (id,manager_id,salary)

select id,manager_id,salary from employees where id>=200 and salary <5000

endif

方法1

1

双击运行PLSQL Developer软件,连接oracle数据库服务器

2

在“对象”下,找到users,右击选择“新建”

3

在d出的“创建用户”窗口中,输入新用户的名称、口令,默认表空间、临时表空间等

4

赋予新用户权限,赋予其角色权限:connect、resource,这样用户才能登录 *** 作数据库

END

方法2

1

通过sql语句创建用户:依次单击“文件”--“新建”--“SQL窗口”

2

输入sql语句:

-- Create the user

create user USER2 --用户名 identified by

user2 --口令 default tablespace USERS

--默认表空间temporary tablespace TEMP --临时表空间

3

单击执行按钮或按快捷键F8,执行sql语句,创建用户

4

输入sql语句:

-- Grant/Revoke role privileges grant connect to USER2grant resource to USER2

给用户赋予权限,按F8执行语句

5

运行plsql,输入新建用户的用户名和口令登录

declare

begin

for v_emp in(

select dept.dname,X.b,emp.ename,emp.sal

from emp

join (select deptno a,round(avg(sal),2) b

from emp

group by deptno) X

on emp.deptno=X.a

and emp.sal>X.b

join dept

on emp.deptno=dept.deptno

order by emp.deptno desc)

loop

dbms_output.put_line('部门名称为:'||v_emp.dname||';平均薪资为:'||v_emp.b||

';高于该部门平均工资的员工为:'||v_emp.ename||';该员工工资为:'||v_emp.sal)

end loop

end


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11761870.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存