数据表中插入数据显示错误提示:未找到父项关键字
数据库建表sql代码如下
目录
--Exper1
create table Employees(
EmployeeID char(6) not null primary key,
Name char(10) not null,
Birthday Date not null,
Sex Number(1) not null,
Address Char(20),
Zip char(6),
PhoneNumber char(12),
DepartmentID char(3) not null references Departments(DepartmentID)
--constraint pk_emp primary key(EmployeeID)
--constraint fk_emp_dep foreign key(DepartmentID) references Departments(DepartmentID)
);
drop table Employees
--Employees表列说明
comment on column Employees.EmployeeID is '部门编号、主键';
comment on column Employees.Name is '姓名';
comment on column Employees.Birthday is '出生日期';
comment on column Employees.Sex is '性别';
comment on column Employees.Address is '地址';
comment on column Employees.Zip is '邮编';
comment on column Employees.PhoneNumber is '电话号码';
comment on column Employees.DepartmentID is '员工部门号、外键';
--Employees表_插入数据
--insert into Employees(EmployeeID,Name,Birthday,Sex,Address,Zip,PhoneNumber,DepartmentID)
insert into Employees(EmployeeID,Name,Birthday,Sex,Address,Zip,PhoneNumber,DepartmentID)
values('011110','小橙' ,to_date('19780620','YYYYMMDD'),'1','解放路100号','210000','4055660','000');
commit;
('010001','小黄' ,to_date('19780621','YYYYMMDD'),1,'解放路101号',210001,4055661,1),
('011112','小红' ,to_date('19780622','YYYYMMDD'),0,'解放路102号',210002,4055662,2),
('011113','小绿' ,to_date('19780623','YYYYMMDD'),1,'解放路103号',210003,4055663,3),
('011114','小黑' ,to_date('19780624','YYYYMMDD'),1,'解放路104号',210004,4055664,4),
('011115','小花' ,to_date('19780625','YYYYMMDD'),0,'解放路105号',210005,4055665,5),
('011116','小蓝' ,to_date('19780626','YYYYMMDD'),1,'解放路106号',210006,4055666,6),
('011117','小紫' ,to_date('19780627','YYYYMMDD'),1,'解放路107号',210007,4055667,7),
('011118','小粉' ,to_date('19780628','YYYYMMDD'),0,'解放路108号',210008,4055668,8);
commit;
create table Departments(
DepartmentID char(3) not null primary key,
DepartmentName char(20) not null,
Note Varchar2(100)
);
--Departments表列说明
comment on column Departments.DepartmentID is '部门编号、主键';
comment on column Departments.DepartmentName is '部门名';
comment on column Departments.Note is '备注';
create table Salary(
EmployeeID char(6) not null primary key,
InCome Number(8,2) not null,
OutCome Number(8,2) not null
);
----Salary表列说明
comment on column Salary.EmployeeID is '员工编号、主键';
comment on column Salary.InCome is '收入';
comment on column Salary.OutCome is '支出';
执行下列语句后提示错误如下: