百度烧饼删删删删NMLGBXXX
create table dept as select * from scott.dept;
create table emp as select * from scott.emp;
alter table emp add constraint pk_emp primary key(empno);
alter table dept add constraint pk_dept primary key(deptno);
ALTER TABLE EMP ADD CONSTRAINT FK_DEPT_EMP FOREIGN KEY(DEPTNO) REFERENCES DEPT(DEPTNO);
alter Table emp add constraint ck_emp check(sal > 0);
set serveroutput on;
declare
n_deptno number;
n_total number;
no_dept exception;
begin
n_deptno:=&n;
select count(deptno)into n_total
from emp where deptno=n_deptno;
if n_total=0 then
raise no_dept;
else
dbms_output.put_line(n_deptno||'部门的总人数'||n_total);
end if;
exception
when no_dept then dbms_output.PUT_line('部门不存在');
end;
create table dept as select * from scott.dept;
create table emp as select * from scott.emp;
alter table emp add constraint pk_emp primary key(empno);
alter table dept add constraint pk_dept primary key(deptno);
ALTER TABLE EMP ADD CONSTRAINT FK_DEPT_EMP FOREIGN KEY(DEPTNO) REFERENCES DEPT(DEPTNO);
alter Table emp add constraint ck_emp check(sal > 0);
set serveroutput on;
declare
n_deptno number;
n_total number;
no_dept exception;
begin
n_deptno:=&n;
select count(deptno)into n_total
from emp where deptno=n_deptno;
if n_total=0 then
raise no_dept;
else
dbms_output.put_line(n_deptno||'部门的总人数'||n_total);
end if;
exception
when no_dept then dbms_output.PUT_line('部门不存在');
end;









