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

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

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

QUESTION 6

Which two statements are true regarding constraints? (Choose two)

A. A constraint is enforced only for an INSERT operation on a table.

B. A foreign key cannot contain NULL values.

C. A column with the UNIQUE constraint can store NULLS.

D. You can have more than one column in a table as part of a primary key.

答案:CD

解析:约束constraints:

  1. 创建表时,有“内联声明”和“外部定义”两种方式,也可修改表时,ALTER .... ADD CONSTRAINT属于外部定义,MODIFY 属于内联声明;
  2. (Composite)PRIMARY KEY:每个值NOT NULL,复合值UNIQUE;
  3. FOREIGN KEY:确保父表中在对应的列上已经存在一个UNIQUE(PRIMARY KEY)约束,且后续添加的值已经存在父表对应列中;
  4. NOT NULL:不能通过外部定义的方式声明,主键不能NOT NULL,外键和UNIQUE可以NOT NULL;
  5. ON DELETE:父表中一行删除,则子表中对应的行或多行也删除。

QUESTION 7

Evaluate the following statement.

INSERT ALL
WHEN order_total < 10000 THEN INTO small_orders
WHEN order_total >10000  AND order_total < 20000 THEN
  		INTO small_orders   
WHEN order_total >200000  AND order_total < 20000 THEN
  		INTO small_orders       
SELECT order_id order_total,customer_id 
FROM orders;

Which statement is true regarding the evaluation of rows returned by the subquery in the INSERT statement?

A. They are evaluated by all the three WHEN clauses regardless of the results of the evaluation of any other WHEN clause.

B. They are evaluated by the first WHEN clause. If the condition is true, then the row would be evaluated by the subsequent WHEN clauses.

C. They are evaluated by the first WHEN clause. If the condition is false, then the row would be evaluated by the subsequent WHEN clauses.

D. The insert statement would give an error because the ELSE clause is not present for support in case none of WHEN clauses are true.

答案:A

解析:条件多表INSERT语句,注意点:

  1. INSERT option...的默认值为ALL(可省略),FIRST是一个可选的option关键字,如果使用了FIRST,只有第一个取值为TRUE的WHEN子句后面的INTO子句才能执行;
  2. 每个WHEN都能跟随一个或多个INTO子句每个INTO子句都拥有自己的VALUES子句,如果省略了VALUES子句,那么插入数据的子查询中的各列;
  3. 如果语句中包含了可选的ELSE。。。INTO子句,那么这个子句必须位于整体语句最后的位置,子查询前。

QUESTION 8

Examine the structure of the MEMBERS table:

Name                          NULL?                 Type

------------------              --------------         ----------------
MEMBER                     NOT NULL           VARCHAR2(6)
FIRST_NAME                                           VARCHAR2(50)
LAST_NAME                NOT NULL           VARCHAR2(50)
ADDREDD                                               VARCHAR2(50)          
CITY                                                        VARCHAR2(25)      
STATE

You want to display details of all members who reside in states starting with the letter A followed by exactly one character.

Which SQL statement must you execute?

A. SELECT * FROM MEMBERS WHERE state LIKE '%A_';

B. SELECT * FROM MEMBERS WHERE state LIKE 'A_';

C. SELECT * FROM MEMBERS WHERE state LIKE 'A_%';

D. SELECT * FROM MEMBERS WHERE state LIKE 'A%';

答案:B

解析:通配符:

  1. 下划线(_),代表一个字符;
  2. 百分号(%),代表零个、一个或多个字符。

QUESTION 9

You want to display 5 percent of the rows from the SALES table for products with the lowest MOUNT_SOLD and also want to include the rows that have the same AMOUNT_SOLD even if this causes the output to exceed 5 percent of the rows.

Which query will provide the required result?

A. SELECT        prod_id, cust_id, amount_sold
 FROM          sales
    ORDER BY   amount_sold
    FETCH FIRST 5 PERCENT ROWS WITH TIES;
B. SELECT        prod_id, cust_id, amount_sold
		FROM        sales
    ORDER BY   amount_sold
    FETCH FIRST 5 PERCENT ROWS ONLY WITH TIES;
C. SELECT        prod_id, cust_id, amount_sold
		FROM         sales
		ORDER BY   amount_sold
		FETCH FIRST 5 PERCENT ROWS WITH TIES ONLY;
D. SELECT        prod_id, cust_id, amount_sold
		FROM          sales
    ORDER BY   amount_sold
    FETCH FIRST 5 PERCENT ROWS ONLY;

答案:A

解析:使用FETCH来指定SELECT语句返回的行数限制,FETCH子句,注意点:

  1. 关键字FIRST/NEXT和ROW/ROWS,两者必选其中一个,语法功能上无区别;
  2. 可指定输入的行数,如果没有指定,FETCH 默认返回一行;
  3. 子句ONLY/WITH TIES 必须有其中一个,ONLY返回指定的行数或比例,无更多的行,WITH TIES返回指定的行和与该行ORDER BY所指定值相同值的行。

QUESTION 10

Examine the structure of the MEMBERS table:

Name                          NULL?                 Type

------------------              --------------         ----------------
MEMBER                     NOT NULL           VARCHAR(6)
FIRST_NAME                                           VARCHAR(50)
LAST_NAME                NOT NULL           VARCHAR(50)
ADDREDD                                               VARCHAR(50)          

You execute the SQL statement:

SQL > SELECT member_id, ' ' , first_name, ' ' , last_name "ID FIRSTNAME LASTNAME" 
           FROM members;

What is the outcome?

A. It fails because the alias name specified after the column names is invalid.

B. It fails because the space specified in single quotation marks after the first two column names is invalid.

C. It executes successfully and displays the column details in a single column with only the alias column heading.

D. It executes successfully and displays the column details in three separate columns and replaces only the last column heading with the alias.

答案:D

解析:SELECT可以通过加引号(' ')命名新的列,并对该列的每列赋值引号中的内容。


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

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

相关推荐

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命令查找类型:二进制文件;...

取消回复欢迎 发表评论: