百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 优雅编程 > 正文

Oracle Database 12c SQL OCA/OCP 1Z0-071题库(21-25题)

sinye56 2024-09-16 14:35 5 浏览 0 评论

QUESTION 21

The BOOKS_TRANSACTIONS table exists in your database.

SQL>SELECT * FROM books_transactions ORDER BY 3;

What is the outcome on execution?

A. The execution fails unless the numeral 3 in the ORDER BY clause is replaced by a column name.

B. Rows are displayed in the order that they are stored in the table only for the three rows with the lowest values in the key column.

C. Rows are displayed in the order that they are stored in the table only for the first three rows.

D. Rows are displayed sorted in ascending order of the values in the third column in the table.

答案:D

解析:ORDER BY,注意点:

  1. ORDER BY 可以通过名称引用,表达式和位置引用进行排序;
  2. 默认升序(ASC),相反的是DESC;
  3. ORDER BY可以应用列别名,SELECT语句执行顺序见第二题解析;
  4. ORDER BY排序中,A~Z~a~z升序,如果是字符型数字,则从第一个字符开始比较。NULL大于一切值

QUESTION 22

Examine the command:

SQL > ALTER TABLE books_transactions
						ADD CONCTRAINT fk_book_id FOREIGN KEY (book_id)
						REFERENCES books (book_id)on DELETE CASCADE;

What does ON DELETE CASCADE imply?

A. When the BOOKS table is dropped, the BOOK_TRANSACTIONS table is dropped.

B. When the BOOKS table is dropped, all the rows in the BOOK_TRANSACTIONS table are deleted but the table structure is retained.

C. When a row in the BOOKS table is deleted, the rows in the BOOK_TRANSACTIONS table whose BOOK_ID matches that of the deleted row in the BOOKS table are also deleted.

D. When a value in the BOOKS.BOOK_ID column is deleted, the corresponding value is updated in the BOOKS_TRANSACTIONS.BOOK_ID column.

答案:C

解析:约束ON DELETE :父表中的某行删除,子表中对应的行或多行也删除。

QUESTION 23

View the exhibit and examine the structure of the EMPLOYEES table.

Name                          NULL?                 Type
------------------              --------------         ----------------
EMPLOYEE_ID              NOT NULL           NUMBER(6)
FIRST_NAME                                           VARCHAR(20)
LAST_NAME              NOT NULL           VARCHAR(25)
HIRE_DATA              NOT NULL           DATE          
JOB_ID              NOT NULL            VARCHAR2(10)
SALARY                                                    NUMBER(10,2)
COMMISSION                                         NUMBER(6,2)
MANAGER_ID                                         NUMBER(6)
DEPARTMENT_ID                                   NUMBER(4)

You want to display all employees and their managers having 100 as the MANAGER_ID. You want the output in two columns: the first column would have the LAST_NAME of the managers and the second column would have LAST_NAME of the employees.

Which SQL statement would you execute?

A. SELECT m.last_name "Manager", e.last_name "Employee"
FROM employees m JOIN employees e
ON m.employee_id = e.manager_id
WHERE m.manager_id = 100;
B. SELECT m.last_name "Manager", e.last_name "Employee"
FROM employees m JOIN employees e
ON m.employee_id = e.manager_id
WHERE e.manager_id = 100;
C. SELECT m.last_name "Manager", e.last_name "Employee"
FROM employees m JOIN employees e
ON e.employee_id = m.manager_id
WHERE m.manager_id = 100;
D. SELECT m.last_name "Manager", e.last_name "Employee"
FROM employees m JOIN employees e
WHERE m.employee_id = e.manager_id AND e.manager_id = 100

答案:B

解析:自连接将同一个表中的列值与该列的值或是另一列的值进行比较,可以是内连接、外连接、等值连接或非等值连接

QUESTION 24

Which three statements are true about multiple-row subqueries?

A. They can contain a subquery within a subquery.

B. They can return multiple columns as well as rows.

C. They cannot contain a subquery within a subquery.

D. They can return only one column but multiple rows.

E. They can contain group functions and GROUP BY and HAVING clauses.

F. They can contain group functions and the GROUP BY clause, but not the HAVING clause.

答案:ABE

解析:子查询一些注意点:

  1. 多行子查询可向父查询返回多行查询结果,对列无限制。关键字ANY/SOME ,父查询中的表达式需要满足子查询的任意结果(类似于OR),关键字ALL,父查询中的表达式需要满足子查询的所有结果(类似于AND)
  2. 子查询可以使用GROUP BY 子句和ORDER BY 子句

QUESTION 25

Examine the structure of the EMPLOYEES table.

Name                          NULL?                 Type
------------------              --------------         ----------------
EMPLOYEE_ID              NOT NULL           NUMBER(6)
FIRST_NAME                                           VARCHAR(20)
LAST_NAME              NOT NULL           VARCHAR(25)
HIRE_DATA              NOT NULL           DATE          
JOB_ID              NOT NULL            VARCHAR2(10)
SALARY                                                    NUMBER(10,2)
COMMISSION                                         NUMBER(6,2)
MANAGER_ID                                         NUMBER(6)
DEPARTMENT_ID                                   NUMBER(4)

There is a parent/child relationship between EMPLOYEE_ID and MANAGER_ID.

You want to display the last names and manager IDs of employees who work for the same manager as the employee whose EMPLOYEE_ID is 123.

Which query provides the correct output?

A. SELECT e.last_name, m.manager_id
FROM employees e RIGHT OUTER JOIN employees m
on (e.manager_id = m.employee_id)
AND e.employee_id = 123;
B. SELECT e.last_name, m.manager_id
FROM employees e LEFT OUTER JOIN employees m
on (e.employee_id = m.manager_id)
WHERE e.employee_id = 123;
C. SELECT e.last_name, e.manager_id
FROM employees e RIGHT OUTER JOIN employees m
on (e.employee_id = m.employee_id)
WHERE e.employee_id = 123;
D. SELECT m.last_name, e.manager_id
FROM employees e LEFT OUTER JOIN employees m
on (e.manager_id = m.manager_id)
WHERE e.employee_id = 123;

答案:D

解析:参见23题解析。


后续陆续更新,转载请注明出处。

本人水平有限,欢迎指正。

相关推荐

Linux在线安装JDK1.8

首先在服务器pingwww.baidu.com查看是否可以连网然后就可以在线下载一、下载安装JDK1.81、在下载安装的同时做好一些准备工作...

Linux安装JDK,超详细

1、了解RPMRPM是Red-HatPackageManager(RPM软件包管理器)的缩写,这一文件格式名称虽然打上了RedHat的标志,但是其原始设计理念是开放式的,现在包括OpenLinux...

Linux安装jdk1.8(超级详细)

前言最近刚购买了一台阿里云的服务器准备要搭建一个网站,正好将网站的一个完整搭建过程分享给大家!#一、下载jdk1.8首先我们需要去下载linux版本的jdk1.8安装包,我们有两种方式去下载安装...

Linux系统安装JDK教程

下载jdk-8u151-linux-x64.tar.gz下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.ht...

干货|JDK下载安装与环境变量配置图文教程「超详细」

1.JDK介绍1.1什么是JDK?SUN公司提供了一套Java开发环境,简称JDK(JavaDevelopmentKit),它是整个Java的核心,其中包括Java编译器、Java运行工具、Jav...

Linux下安装jdk1.8

一、安装环境操作系统:CentOSLinuxrelease7.6.1810(Core)JDK版本:1.8二、安装步骤1.下载安装包...

Linux上安装JDK

以CentOS为例。检查是否已安装过jdk。yumlist--installed|grepjdk或者...

Linux系统的一些常用目录以及介绍

根目录(/):“/”目录也称为根目录,位于Linux文件系统目录结构的顶层。在很多系统中,“/”目录是系统中的唯一分区。如果还有其他分区,必须挂载到“/”目录下某个位置。整个目录结构呈树形结构,因此也...

Linux系统目录结构

一、系统目录结构几乎所有的计算机操作系统都是使用目录结构组织文件。具体来说就是在一个目录中存放子目录和文件,而在子目录中又会进一步存放子目录和文件,以此类推形成一个树状的文件结构,由于其结构很像一棵树...

Linux文件查找

在Linux下通常find不很常用的,因为速度慢(find是直接查找硬盘),通常我们都是先使用whereis或者是locate来检查,如果真的找不到了,才以find来搜寻。为什么...

嵌入式linux基本操作之查找文件

对于很多初学者来说都习惯用windows操作系统,对于这个系统来说查找一个文件简直不在话下。而学习嵌入式开发行业之后,发现所用到的是嵌入式Linux操作系统,本想着跟windows类似,结果在操作的时...

linux系统查看软件安装目录的方法

linux系统下怎么查看软件安装的目录?方法1:whereis软件名以查询nginx为例子...

Linux下如何对目录中的文件进行统计

统计目录中的文件数量...

Linux常见文件目录管理命令

touch用于创建空白文件touch文件名称mkdir用于创建空白目录还可以通过参数-p创建递归的目录...

Linux常用查找文件方法总结

一、前言Linux系统提供了多种查找文件的命令,而且每种查找命令都具有其独特的优势,下面详细总结一下常用的几个Linux查找命令。二、which命令查找类型:二进制文件;...

取消回复欢迎 发表评论: