面某小公司DBA考到的三道数据库比试题 面某小公司DBA考到的三道数据库比试题 大家看看 最好能解释一下 题目1: Given the following CREATE TABLE statement: CREATE TABLE department (deptid INTEGER, deptname CHAR(25), budget NUMERIC(12,2)) Which of the following statement prevents two departments from being assigned the same DEPTID, but allows null values? A ALTER TABLE department ADD CONSTRAINT dpt_cst PRIMARY KEY(deptid) B CREATE INDEX dpt_idx ON department(deptid) C ALTER TABLE department ADO CONSTRAINT dpt_cst UNIQUE(deptid) D CREATE UNIQUE INDEX dpt_idx ON department(deptid)
题目2:Use the ERD to help you answer the following two questions (看下图链接,回答以下两个问题)
问1:Find all ISBN values in the EDITION table, for all FORMAT='Hardcover' books.
问2 Find the sum of all LIST_PRICE values in the EDITION table, for each publisher.
题目3:What is database transaction?
------解决方案-------------------- 1. A
------解决方案-------------------- 错了,应该是1. C
------解决方案-------------------- 1题: 选B 2题:1问:select ISBN from EDITION where FORMAT='Hardcover' 2问:select LIST_PRICE from EDITION A left outer join Publisher B on B.Publisher_ID=A.Publisher_ID 3题:只能意会不能言传,呵呵。查下帮助吧。 (数据库事务是指作为单个逻辑工作单元执行的一系列操作。bengin transaction, rollback transaction,commit transaction)
--1)
select ISBN from EDITION where FORMAT='Hardcover'
--2)
select publisher_id,sum(LIST_PRICE) from EDITION group by publisher_id
------解决方案-------------------- 题目1: Given the following CREATE TABLE statement: CREATE TABLE department (deptid INTEGER, deptname CHAR(25), budget NUMERIC(12,2)) Which of the following statement prevents two departments from being assigned the same DEPTID, but allows null values? 下面哪项可以屏蔽同时出现DEPTID值,但允许为空? 我的答案:C(唯一主键) A ALTER TABLE department ADD CONSTRAINT dpt_cst PRIMARY KEY(deptid) --主键,肯定不允许为null啦 B CREATE INDEX dpt_idx ON department(deptid) --索引 C ALTER TABLE department ADO CONSTRAINT dpt_cst UNIQUE(deptid) -- D CREATE UNIQUE INDEX dpt_idx ON department(deptid) --唯一索引
题目2:Use the ERD to help you answer the following two questions (看下图链接,回答以下两个问题)
问1:Find all ISBN values in the EDITION table, for all FORMAT='Hardcover' books.--在EDITION 表中查询所有FORMAT='Hardcover' 的ISBN, select ISBN from EDITION where FORMAT='Hardcover'