Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. create table jobs(job_id INT primary key,
  2.                  job_name varchar(20) not null unique,
  3.                  min_salary numeric(8,2)not null check(min_salary>1500),
  4.                  max_salary numeric(8,2)not null check(min_salary>1500))
  5.  
  6.  
  7. create table employees(emp_id INT primary key,
  8.                  first_name varchar(30) not null ,
  9.                  last_name varchar(30) not null ,
  10.                  salary numeric(8,2)not null check(salary>1500),
  11.                        manager_id int references employees(emp_id),
  12.                  job_id int not null references jobs(job_id) deferrable initially deferred);
  13.  
  14.  
  15.  
  16.  
  17. begin;
  18. insert into employees values(1,'a','b',2000,null,1);
  19. insert into jobs values (1, 'CEO',10000,15000);
  20. commit;
  21.  
  22. begin;
  23. delete from employees where job_id=3;
  24. rollback;
  25. commit;
  26.  
  27.  
  28. begin;
  29. insert into employees values(4,'g','h',2000,1,3);
  30. insert into jobs values (3, 'HR',2000,5000);
  31. commit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement