ID: 21350338

3.1.3《建立表之间的联系》-课后作业 粤教版(2019)-信息技术-数据管理与分析选修3

日期:2024-11-23 科目:信息技术 类型:高中试卷 查看:40次 大小:14812B 来源:二一课件通
预览图 1/2
3.1.3,2019,选修,分析,数据管理,信息技术
  • cover
《建立表之间的联系》作业 一、选择题 1. 在SQL中,以下哪个命令用于创建外键约束? A. CREATE FOREIGN KEY B. ALTER TABLE ... ADD FOREIGN KEY C. CREATE TABLE ... FOREIGN KEY D. ALTER TABLE ... ADD CONSTRAINT 答案:D 解析:ALTER TABLE ... ADD CONSTRAINT命令用于创建外键约束。外键是一种数据库约束,用于确保一个表中的数据与另一个表中的数据相匹配,以维护数据的一致性和完整性。 2. 在MySQL中,要删除一个外键约束,应使用以下哪个命令? A. DELETE FOREIGN KEY B. REMOVE FOREIGN KEY C. ALTER TABLE ... DROP FOREIGN KEY D. DROP FOREIGN KEY 答案:C 解析:ALTER TABLE ... DROP FOREIGN KEY命令用于删除MySQL中的外键约束。执行此操作后,外键约束将被移除,但相关的数据列仍然存在。 3. 在PostgreSQL中,要创建一个名为“fk_department_id”的外键约束,引用“departments”表中的“id”列,应使用以下哪个语法? A. ALTER TABLE employees ADD CONSTRAINT fk_department_id FOREIGN KEY (department_id) REFERENCES departments(id); B. ALTER TABLE employees ADD fk_department_id FOREIGN KEY (department_id) REFERENCES departments(id); C. ALTER TABLE employees ADD CONSTRAINT fk_department_id FOREIGN KEY (id) REFERENCES departments(department_id); D. ALTER TABLE employees ADD CONSTRAINT fk_department_id FOREIGN KEY (department_id) REFERENCES departments(department_id); 答案:A 解析:正确的语法是ALTER TABLE employees ADD CONSTRAINT fk_department_id FOREIGN KEY (department_id) REFERENCES departments(id);。这会创建一个名为“fk_department_id”的外键约束,确保“employees”表中的“department_id”列引用“departments”表中的“id”列。 4. 在SQL Server中,要创建一个名为“FK_Employee_Department”的外键约束,引用“Departments”表中的“DepartmentID”列,应使用以下哪个语法? A. ALTER TABLE Employees ADD CONSTRAINT FK_Employee_Department FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID); B. ALTER TABLE Employees ADD FK_Employee_Department FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID); C. ALTER TABLE Employees ADD CONSTRAINT FK_Employee_Department FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID); D. ALTER TABLE Employees ADD FK_Employee_Department FOREIGN KEY (EmployeeID) REFERENCES Departments(DepartmentID); 答案:C 解析:正确的语法是ALTER TABLE Employees ADD CONSTRAINT FK_Employee_Department FOREIGN KEY (DepartmentID) REFERENCES Departments(DepartmentID);。这会创建一个名为“FK_Employee_Department”的外键约束,确保“Employees”表中的“DepartmentID”列引用“Departments”表中的“DepartmentID”列。 5. 在Oracle数据库中,要创建一个名为“FK_EMP_DEPT”的外键约束,引用“DEPARTMENTS”表中的“DEPT_ID”列,应使用以下哪个语法? A. ALTER TABLE EMPLOYEES ADD CONSTRAINT FK_EMP_DEPT FOREIGN KEY (DEPT_ID) REFERENCES DEPARTMENTS(DEPT_ID); B. ALTER TABLE EMPLOYEES ADD FK_EMP_DEPT FOREIGN KEY (DEPT_ID) REFERENCES DEPARTMENTS(DEPT_ID); C. ALTER TABLE EMPLOYEES ADD CONSTRAINT FK_EMP_DEPT FOREIGN KEY (EMP_DEPT) REFERENCES DEPARTMENTS(DEPT_ID); D. ALTER TABLE EMPLOYEES ADD CONSTRAINT FK_EMP_DEPT FOREIGN KEY (EMP_ID) REFERENCES DEPARTMENTS(DEPT_ID); 答案:A 解析:正确的语法是ALTER TABLE EMPLOYEES AD ... ...

~~ 您好,已阅读到文档的结尾了 ~~