为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);
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 关联表(关联键名)
- 设置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);
- 设置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);
- 图书借阅系统中,用户想实现向数据表“借阅”中添加主键,该如何操作( ). A: alter table 借阅 add constraint pk_b primary key(学号) B: alter table 借阅 add constraint pk_b primary key(书号) C: alter table 借阅 add constraint pk_b primary key(学号,书号) D: alter table 借阅 add constraint pk_b unique(学号,书号)