设置score表的sid列为外键,关联stu表的sid列,可以使用以下哪条命令实现。
A: alter table stu add constraint fk_sid foreign key(sid) references stu(sid);
B: alter table stu add constraint fk_sid foreign key(sid) references score(sid);
C: alter table score add constraint fk_sid foreign key(sid) references sore(sid);
D: alter table score add constraint fk_sid foreign key(sid) references stu(sid);
A: alter table stu add constraint fk_sid foreign key(sid) references stu(sid);
B: alter table stu add constraint fk_sid foreign key(sid) references score(sid);
C: alter table score add constraint fk_sid foreign key(sid) references sore(sid);
D: alter table score add constraint fk_sid foreign key(sid) references stu(sid);
举一反三
- 设置score表的sid列为外键,关联stu表的sid列,可以使用以下哪条命令实现。() A: alter table stu<br> add constraint fk_sid foreign key(sid) references stu(sid); B: alter table stu<br> add constraint fk_sid foreign key(sid) references score(sid); C: alter table score<br> add constraint fk_sid foreign key(sid) references sore(sid); D: alter table score<br> add constraint fk_sid foreign key(sid) references stu(sid);
- 删除stu表,建立在sid列上的主键,可使用以下哪条命令。 A: alter table stu drop primary keys; B: alter table stu drop primary key; C: alter table stu drop primary key sid; D: alter table stu drop constraint sid;
- 为salerecord表CID字段添加外键,引用client表中CID字段。 A: ALTER TABLE salerecord ADD CONSTRAINT fk1 FOREIGN KEY(CID) REFERENCES client(CID); B: ALTER TABLE salerecord ADD CONSTRAINT pk1 PRIMARY KEY(CID) REFERENCES client(CID); C: ALTER TABLE salerecord ADD CONSTRAINT fk1 FOREIGN KEY(CID) REFERENCES client(CID),ADD CONSTRAINT pk2 PRIMARY KEY(GID) REFERENCES goods(GID); D: ALTER TABLE salerecord ADD CONSTRAINT pk1 PRIMARY KEY(CID) REFERENCES client(CID),ADD CONSTRAINT pk2 PRIMARY KEY(GID) REFERENCES goods(GID);
- 为salerecord表GID字段添加外键,引用goods表中GID字段。 A: ALTER TABLE salerecord ADD CONSTRAINT pk2 PRIMARY KEY(GID) REFERENCES goods(GID); B: ALTER TABLE salerecord ADD CONSTRAINT fk2 FOREIGN KEY(GID) REFERENCES goods(GID); C: ALTER TABLE salerecord ADD CONSTRAINT fk2 FOREIGN KEY(CID) REFERENCES goods(CID); D: ALTER TABLE salerecord ADD CONSTRAINT pk2 PRIMARY KEY(CID) REFERENCES goods(CID);
- 如何在已经创建好的表上添加一个外键约束:。 A: alter table 表名 add constraint foreign key (键名) references 关联表(关联键名) B: alter table 表名 add primary key (键名) references 关联表(关联键名) C: alter table 表名 add foreign key (键名) references (关联键名) D: alter table 表名 add constraint primary key (键名) references 关联表(关联键名)