sql的问题,求解答。
执行下列Sql语句后 ,选项中的插入语句能正确执行的是
SQL> create table major(
id number(2) primary key,
name char(20)
);
SQL> insert into major values(1, 'computer');
SQL> insert into major values(2, 'history');
SQL> commit ;
SQL>create table student(
sid number(3),
name varchar2(20) not null,
gender char(1),
majorid number(2),
constraint stu_n4_sid_pk primary key(sid),
constraint stu_n4_mid_fk
foreign key (majorid) references major(id)
);
SQL> insert into student values(101, 'amy', 'F', 1);
SQL> commit ;
A.insert into student(name,majorid) values( 'amy', 1);
B.insert into student values(101, 'amy', 'F', 1);
C.insert into student(sid,name) values(102, 'amy');
D.insert into student(sid,name,majorid) values(103, 'amy',3);
答案是C,
为什么B不是呢?
------解决方案--------------------
当然不是B啦
student明显有主外键关联,而且,它本身已经一条101的记录了