create table Emp
(
eid char(20) primary key,
ename char(20),
age integer check (age > 0),
did char(20),
salary float,
)
create table Dept
(
did char(20) primary key,
dname char(20),
mgr_did char(20),
)
alter table Emp add constraint fk_emp_did foreign key (did) references Dept(did)
alter table Dept add constraint fk_dept_mgrdid foreign key (mgr_did) references Emp(eid)
select * from Emp a, Dept b, Emp c where a.did = b.did and b.mgr_did = c.eid and a.salary > 10000 and a.age = c.age;
时间: 2024-10-10 04:31:04