资源预览内容
第1页 / 共12页
第2页 / 共12页
第3页 / 共12页
第4页 / 共12页
第5页 / 共12页
第6页 / 共12页
第7页 / 共12页
第8页 / 共12页
第9页 / 共12页
第10页 / 共12页
亲,该文档总共12页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
1、哪一个SQL有错误?A. SELECT * FROM emp_dept_vu;B. SELECT department_id, SUM(salary) FROM emp_dept_vuGROUP BY department_id;C. SELECT department_id, job_id, AVG(salary)FROM emp_dept_vuGROUP BY department_id, job_id;D. SELECT job_id, SUM(salary)FROM emp_dept_vuWHERE department_id IN (10,20)GROUP BY job_idHAVING SUM(salary) 20000;E. 没有一个错误,都是对的.2、两张表结构如下:EMPLOYEES(EMPLOYEE_ID NUMBER Primary KeyFIRST_NAME VARCHAR2(25)LAST_NAME VARCHAR2(25)HIRE_DATE DATE)NEW_EMPLOYEES(EMPLOYEE_ID NUMBER Primary KeyNAME VARCHAR2(60))哪一个删除语句是正确的。A. DELETE FROM employeesWHERE employee_id = (SELECT employee_idFROM employees);B. DELETE * FROM employeesWHERE employee_id = (SELECT employee_idFROM new_employees);C. DELETE FROM employeesWHERE employee_id IN (SELECT employee_idFROM new_employeesWHERE name =Carrey);D. DELETE * FROM employeesWHERE employee_id IN (SELECT employee_idFROM new_employeesWHERE last_name =Carrey);3、显示每个部门,最高SALARY,最小SALARY,且最小SALARY小于5000,最大SALARY大于15000。A. SELECT dept_id, MIN(salary), MAX(salary)FROM employeesWHERE MIN(salary) 15000;B. SELECT dept_id, MIN(salary), MAX(salary)FROM employeesWHERE MIN(salary) 15000GROUP BY dept_id;C. SELECT dept_id, MIN(salary), MAX(salary)FROM employeesHAVING MIN(salary) 15000;D. SELECT dept_id, MIN(salary), MAX(salary)FROM employeesGROUP BY dept_idHAVING MIN(salary) 15000;E. SELECT dept_id, MIN(salary), MAX(salary)FROM employeesGROUP BY dept_id, salaryHAVING MIN(salary) 15000;4、执行SQL:SELECT * FROM ordersWHERE cust_id = (SELECT cust_id FROM customers WHERE cust_name = Smith);5、students表结构如下:STD_ID NUMBER(4)COURSE_ID VARCHAR2(10)START_DATE DATEEND_DATE DATE哪两个在列START_DATE上的运算是正确的?A. SUM(start_date)B. AVG(start_date)C. COUNT(start_date)D. AVG(start_date, end_date)E. MIN(start_date)F. MAXIMUM(start_date)6、EMPLOYEES表结构如下:EMP_ID NUMBER(4) NOT NULLLAST_NAME VARCHAR2(30) NOT NULLFIRST_NAME VARCHAR2(30)DEPT_ID NUMBER(2)哪个SQL语句实现last_name 为 Smith不同DEPT_ID的总数?A. SELECT COUNT(*)FROM employeesWHERE last_name=Smith;B. SELECT COUNT(dept_id)FROM employeesWHERE last_name=Smith;C. SELECT DISTINCT(COUNT(dept_id)FROM employeesWHERE last_name=Smith;D. SELECT COUNT(DISTINCT dept_id)FROM employeesWHERE last_name=Smith;E. SELECT UNIQUE(dept_id)FROM employeesWHERE last_name=Smith;7、查询所有employees表中的数据,无论在departments表中是否department_id的记录。哪个查询是正确的?A. SELECT last_name, department_nameFROM employees NATURAL JOIN departments;B. SELECT last_name, department_nameFROM employees JOIN departments ;C. SELECT last_name, department_nameFROM employees e JOIN departments dON (e.department_id = d.department_id);D. SELECT last_name, department_nameFROM employees eRIGHT OUTER JOIN departments d ON (e.department_id = d.department_id);E. SELECT last_name, department_nameFROM employees FULL JOIN departmentsON (e.department_id = d.department_id);F. SELECT last_name, department_nameFROM employees e LEFT OUTERJOIN departments d ON (e.department_id = d.department_id);8、执行以下SQL,哪个结果是正确的。SELECT e.employee_id Emp_id, e.emp_name Employee, e.salary,m.employee_id Mgr_id, m.emp_name ManagerFROM employees e JOIN employees mON (e.mgr_id = m.employee_id)AND e.salary 4000;9、N张表等值联合查询,至少要写几个连接条件?A. NB. N-1C. N+110、哪三个查询没有问题?A. SELECT *FROM employeeswhere salary (SELECT MIN(salary)FROM employeesGROUP BY department_id);B. SELECT *FROM employeesWHERE salary = (SELECT AVG(salary)FROM employeesGROUP BY department_id);C. SELECT distinct department_idFROM employeesWHERE salary ANY (SELECT AVG(salary)FROM employeesGROUP BY department_id);D. SELECT department_idFROM employeesWHERE salary ALL (SELECT AVG(salary)FROM employeesGROUP BY department_id);E. SELECT last_nameFROM employeesWHERE salary ANY (SELECT MAX(salary)FROM employeesGROUP BY department_id);F. SELECT department_idFROM employeesWHERE salary ALL (SELECT AVG(salary)FROM employeesGROUP BY AVG(SALARY);判断题:11、Insert into table_1(id,name) values(seq_table_1.nextval,test);这条SQL会报错( )12、select * from table_1 where create_dt = to_date(2010-01-02 12:23:45,yyyy-mm-dd hh:mi:ss)这条SQL没有问题 ( )13、查询时使用索引一定能加快查询速度。( )14、取表中的前40条记录,以下SQL没有问题( )select t.*,rownum rn from ( select * from table_1 Where create_dt between sysdate - 100 and sysdate order by create_dt desc) t where rownum =4015、表table_1中的记录Id name1 aa2 bb3 cc表table_2中的记录ID name2 cc4 dd5 ff执行如下SQL,Select id from table_1UnionSelect id from table_2如果为:ID123245如果正确( )16、表EMPLOYEES如构如下:EMPLOYEE_ID NUMBER Primary KeyFIR
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号