11g oracle OCP 047題庫解析
51. View the Exhibit and examine the description of the EMPLOYEES table.
You want to know the EMPLOYEE_ID and FIRST_NAME of all the records in the EMPLOYEES table
wherein the JOB_ID column has ST_CLERK or ST_MAN values,
在JOB_ID列裡有ST_CLERK或ST_MAN的值
the DEPARTMENT_ID column has value 30,
DEPARTMENT_ID =30
and the SALARY column has a value greater than 3,000.
SALARY>3000
Which SQL statement would get you the desired result?
題目的要求是:
(like '%CLERK' or like '%MAN')and DEPARTMENT_ID =30 and SALARY>3000
( a or b )and c and d
==>(a and c and d)or (b and c and d)
A. SELECT employee_id, first_name
FROM employees
WHERE job_id like 'MAN%' OR job_id like 'CLERK%'
AND department_id = 30 AND salary > 3000
邏輯正確,要求含有ST_CLERK,ST_MAN,萬用字元為%CLERK,%MAN
B. SELECT employee_id, first_name
FROM employees
WHERE job_id like '%MAN' OR job_id like '%CLERK'
AND (department_id = 30 OR salary > 3000)
department_id = 30,salary > 3000其一為假,結果可以為真,與題意不符
C. SELECT employee_id, first_name
FROM employees
WHERE (job_id like '%MAN' AND job_id like '%CLERK')
AND department_id = 30 OR salary > 3000?
salary > 3000皆為假,結果可以為真,與題意不符
D. SELECT employee_id, first_name (right)
FROM employees
WHERE (job_id like '%MAN' OR job_id like '%CLERK' )
AND department_id = 30 AND salary > 3000?
52. View the Exhibit and examine the structure of the ORDERS table.
The ORDERS table belongs to the user OE. HR is another user in the database.
Evaluate the commands issued by users OE and HR in the following order:
Statement 1 by user OE: GRANT SELECT, UPDATE(customer_id, order_total) ON orders TO hr;
Statement 1 by user HR: SELECT * FROM oe.orders;
Statement 2 by user HR: UPDATE oe.orders SET order_total= 10000;
Which statement is true regarding the above commands?
A. Statement 1 by user OE would not work because the statement has to be issued by the DBA.
ORDERS的主人是oe,oe可以將該表的物件許可權授予別人
B. Statement 2 by user HR would not work because the grant is only for SELECT in a subquery of update.
Oracle的新特性可以將表中某幾列的物件許可權授予別人,oe授予hr對customer_id, order_total兩列的update許可權
C. There are no errors in the statements issued by OE and HR, all the statements would execute successfully. (right)
D. Statement 1 by user HR would not work because SELECT and UPDATE privileges have been granted only on CUSTOMER_ID and ORDER_TOTAL columns.
的確UPDATE許可權只給了CUSTOMER_ID和ORDER_TOTAL兩列,但是select許可權是給了全表的
53. View the Exhibit and examine the structure of the ORDER_ITEMS table.
You need to display the ORDER_ID of the order that has the highest total value among all the orders in
the ORDER_ITEMS table.
Which query would produce the desired output?
正確答案是:
select order_id
from order_items
group by order_id
having sum(unit_price*quantity)=(
select max(sum(unit_price*quantity))
from order_items
group by order_id
)
A. SELECT order_id
FROM order_items
WHERE(unit_price*quantity) = MAX(unit_price*quantity)
GROUP BY order_id
max()聚合函式不能用於where條件
B. SELECT order_id
FROM order_items
WHERE(unit_price*quantity) = (SELECT MAX(unit_price*quantity)
FROM order_items)
GROUP BY order_id
一個order_id有多行記錄,(SELECT MAX(unit_price*quantity) FROM order_items)只能找到一行的最大值,結果沒有實際意義
C. SELECT order_id
FROM order_items
WHERE (unit_price*quantity) = (SELECT MAX(unit_price*quantity)
FROM order_items
GROUP BY order_id)
子查詢返回的是GROUP BY order_id以後最大的單行unit_price*quantity,與題意不符
D. SELECT order_id (right)
FROM order_items
GROUP BY order_id
HAVING SUM(unit_price*quantity) =(SELECT MAX(SUM(unit_price*quantity))
FROM order_items GROUP BY order_id)
54. Which two statements are true about sequences created in a single instance database? (Choose two.)
A. The numbers generated by a sequence can be used only for one table.
翻譯: 序列產生的數字只能被用於一個表
解釋: 可以用於幾個標,序列不是基於表建立的。
B. DELETE
解釋: 刪除序列用drop sequence sequence_name
C. CURRVAL is used to refer to the last sequence number that has been generated. (right)
翻譯: CURRVAL用來提交序列最後產生的數字
D. When the MAXVALUE limit for a sequence is reached, you can increase the MAXVALUE limit by using the ALTER SEQUENCE statement. (right)
翻譯: 當序列達到最大值限制時,你可以透過alter sequence語句來增加最大值限制
E. When a database instance shuts down abnormally, the sequence numbers that have been cached but not used would be available once again when the database instance is restarted.
翻譯: 當資料庫例項非正常關閉,進入快取但是沒有使用的序列數字可以在資料庫例項重新啟動後再次有效。
解釋: 資料庫非正常關閉會丟失已經讀入快取的序列數字,這些數字將永遠丟失
序列的最大值、最小值,步進都是可以透過alter sequence更改的,但是序列的當前值不能用alter sequence更改,要多次呼叫sequence.netvalue來改變
55. View the Exhibit and examine the structure of the EMPLOYEES and DEPARTMENTS tables.
Which SET operator would you use in the blank space in the following SQL statement to list the
departments where all the employees have managers?
要求顯示所有的僱員有經理的部門
SELECT department_id FROM departments 返回的是所有的部門
SELECT department_id FROM employees WHERE manager_id IS NULL?返回的是所有沒有經理的部門
所以2個集合的差集就是所有有經理的部門
SELECT department_id
FROM departments
____
SELECT department_id
FROM employees
WHERE manager_id IS NULL?
A. UNION
交集並且去除重複記錄
B. MINUS (right)
差集
C. INTERSECT
並集
D. UNION ALL
交集不去除重複記錄
56. Which mandatory(強制性的) clause has to be added to the following statement to successfully create an external table called EMPDET?
CREATE TABLE empdet (
empno CHAR(2),
ename CHAR(5),
deptno NUMBER(4)
)
ORGANIZATION EXTERNAL (
LOCATION ('emp.dat')
);
A. TYPE
type 資料轉換驅動器,oracle_loader為預設,也可以改換其他如databump
B. REJECT LIMIT
REJECT LIMIT遇到錯誤退出,0為預設值,可以指定值或使用unlimited
C. DEFAULT DIRECTORY (right)
DEFAULT DIRECTORY工作目錄,必須顯式指定外部表的目錄路徑,不設定工作目錄是無法建立外部表的
D. ACCESS PARAMETERS
轉換引數,如列分割符,錯誤的設定不會妨礙對外部表的建立,但是訪問外部表時會出錯
舉例:
CREATE TABLE "USERLIST" (
ID NUMBER,
USERNAME VARCHAR2(30),
EMAIL VARCHAR2(128)
)
ORGANIZATION external (
TYPE oracle_loader
DEFAULT DIRECTORY TEMP
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCII
BADFILE 'TEMP':'userlist.bad'
DISCARDFILE 'TEMP':'userlist.dis'
LOGFILE 'TEMP':'user.log'
READSIZE 1048576
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
MISSING FIELD VALUES ARE NULL
REJECT ROWS WITH ALL NULL FIELDS
)
location (
'userlist.txt'
)
)
REJECT LIMIT UNLIMITED
57. View the Exhibit and examine the description of the ORDER_ITEMS and PRODUCT_INFORMATION tables.
The ORDER_ITEM table has records pertaining to details for each product in an order.
The PRODUCT_INFORMATION table has records for all the products available for ordering.
Evaluate the following SQL statement:
SELECT oi.order_id, pi.product_id
FROM order_items oi RIGHT OUTER JOIN product_information pi
ON (oi.product_id=pi.product_id);
右外連線,顯示product_information表的所有記錄和能夠和product_information 連線的order_items 表記錄
Which statement is true regarding the output of this SQL statement?
A. The query would return the ORDER_ID and PRODUCT_ID for only those products that are ordered.
翻譯: 查詢返回那些被訂購的產品的ORDER_ID和PRODUCT_ID
解釋: 應該返回所有PRODUCT_ID和被訂購的ORDER_ID
B. The query would return the ORDER_ID and PRODUCT_ID for the products that are ordered as well as for the products that have never been ordered.(right)
翻譯: 查詢返回那些被訂購和沒有被訂購的產品的ORDER_ID和PRODUCT_ID
C. The query would return the ORDER_ID and PRODUCT_ID for the products that are ordered but not listed in the PRODUCT_INFORMATION table.
翻譯: 查詢返回那些被訂購的但是沒有在PRODUCT_INFORMATION表中列出的產品的ORDER_ID和PRODUCT_ID
解釋: 這個是左外連線的含義,題目是右外連線
D. The query would return the ORDER_ID and PRODUCT_ID for those products that are ordered as well as for the products that have never been ordered, and for the products that are not listed in the PRODUCT_INFORMATION table.
翻譯: 查詢返回那些被訂購和沒有被訂購的產品,還有沒有在PRODUCT_INFORMATION表中列出的產品的ORDER_ID和PRODUCT_ID
解釋: 這個是全外連線的含義,題目是右外連線
58. Evaluate the following statement:
CREATE TABLE bonuses(
employee_id NUMBER,
bonus NUMBER DEFAULT 100
);
The details of all employees who have made sales need to be inserted into the BONUSES table.
有銷售的僱員的詳細情況需要插入BONUSES表。
You can obtain the list of employees who have made sales based on the SALES_REP_ID column of the ORDERS table.
你可以用過ORDERS表的SALES_REP_ID列獲得有銷售的僱員的列表。
The human resources manager now decides that employees with a salary of $8,000 or less should receive a bonus.
人力資源經理現在決定有8000美元或以下工資的僱員將得到獎勵
Those who have not made sales get a bonus of 1% of their salary.
那些沒有銷售的人獲得他們工資1%的獎勵
Those who have made sales get a bonus of 1% of their salary and also a salary increase of 1%.
那些有銷售的人獲得他們工資1%的獎勵並且工資增加1%
The salary of each employee can be obtained from the EMPLOYEES table.
每個僱員的工資可以在EMPLOYEES表獲得。
本題要求向bonuses表插入僱員工資1%的記錄,並修改僱員的工資為原來工資的101%
只有merge可以同時insert和update
insert語句可以有選擇性的插入多條記錄到多張表,但是沒有辦法去update記錄。
Which option should be used to perform this task most efficiently?
A. MERGE (right)
B. Unconditional INSERT
沒有update功能
C. Conditional ALL INSERT
沒有update功能
D. Conditional FIRST INSERT
沒有update功能
59. Which statement is true regarding the ROLLUP operator specified in the GROUP BY clause of a SQL statement?
A. It produces only the subtotals for the groups specified in the GROUP BY clause.
翻譯: 他只對在groupby條件中指定的分組產生分類彙總
解釋: rollup會自右向左對每一列進行彙總
B. It produces only the grand totals for the groups specified in the GROUP BY clause.
翻譯: 他只對groupby條件中指定的分組做總和
解釋: rollup會自右向左對每一列進行彙總
C. It produces higher-level subtotals, moving from right to left through the list of grouping columns specified in the GROUP BY clause. (right)
翻譯: rollup會自右向左對分組列表中的列進行高水平的彙總
D. It produces higher-level subtotals, moving in all the directions through the list of grouping columns specified in the GROUP BY clause.
翻譯: rollup會全方向的對分組列表中的列進行高水平的彙總
解釋: rollup只會從右向左
60. View the Exhibit and examine DEPARTMENTS and the LOCATIONS tables.
Evaluate the following SQL statement:
SELECT location_id, city
FROM locations l
WHERE NOT EXISTS (
SELECT location_id
FROM departments
WHERE location_id <> l.location_id
);
This statement was written to display LOCATION_ID and CITY where there are no departments located.
要求顯示沒有部門的城市
sql的流程是:
從location表中找出1條記錄,
查詢子查詢是否有返回結果
子查詢的結果是返回department表中不在外查詢中得到的城市的部門資訊,一般來說子查詢肯定存在返回值
所以not exists一個非空集合返回false,也就是說該查詢得不到任何結果
Which statement is true regarding the execution and output of the command?
A. The statement would execute and would return the desired results.
返回空集,沒有得到想要的結果
B. The statement would not execute because the = comparison operator is missing in the WHERE clause of the outer query.
exists只判斷子查詢返回的集合是否為空,並不針對欄位,所以加上等號反而出錯
C. The statement would execute but it will return zero rows because the WHERE clause in the inner query should have the = operator instead of <>.(right)
等號替換掉不等號,子查詢將會搜尋出在location_id上的部門的集合,然後not exists就可以得到沒有部門的 location_id了
D. The statement would not execute because the WHERE clause in the outer query is missing the column name for comparison with the inner query result.
exists只判斷子查詢返回的集合是否為空,並不針對欄位,所以加上列名反而出錯
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29654823/viewspace-1253411/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【OCP最新題庫解析(052)--題9】You want to install Oracle 11g databaseOracleDatabase
- Oracle ocp 052題庫解析2Oracle
- Oracle 11g 052題庫解析1Oracle
- 【OCP|052】OCP最新題庫解析(052)--小麥苗解答版
- Oracle OCP(36):DBCA建庫Oracle
- NPM酷庫047:ini,解析INI配置檔案NPM
- 【OCP最新題庫解析(052)--題5】Which two are true about roles?
- 【OCP最新題庫解析(052)--題7】 Examine theses SQL statements and outputSQL
- 【OCP最新題庫解析(052)--題1】Which is true about the SYSTEM and SYSAUX...UX
- 【OCP最新題庫解析(052)--題3】Which two are true about external tables?
- 【OCP最新題庫解析(052)--題4】Which four are true about the tools used to?
- 【OCP最新題庫解析(052)--題8】Which two are true about undo tablespaces?
- 【OCP最新題庫解析(052)--題10】 Which two are true about the Archive (ARCnHive
- 【OCP最新題庫解析(052)--題2】...is true about FAST_START_MTTR_TARGETAST
- 【OCP最新題庫解析(052)--題6】Which structure can span multiple data filesStruct
- Oracle 11g刪除庫重建Oracle
- Oracle 19c OCP 1Z0-083題庫(7-12)Oracle
- oracle ocp 19c考題,科目082考試題-Oracle NetOracle
- Oracle OCP(56)Oracle
- Oracle OCP(23):序列Oracle
- Oracle OCP(29):PROFILEOracle
- Oracle OCP(54):EXPOracle
- Oracle OCP(54):IMPOracle
- Oracle OCP(57):IMPDPOracle
- Oracle OCP(44):LSNRCTLOracle
- Oracle OCP(28):USEROracle
- Oracle OCP(25):索引Oracle索引
- Oracle OCP(30):ROLEOracle
- 有關考11g OCP的重要通知!
- 11G oracle資料庫重新啟動crsOracle資料庫
- 靜默安裝Oracle資料庫11gOracle資料庫
- Oracle 11g用impdp還原資料庫Oracle資料庫
- 【配置上線】Oracle靜默建庫 for 11gOracle
- Oracle OCP(33):官方文件Oracle
- Oracle OCP(20):建立表Oracle
- Oracle OCP(21):管理表Oracle
- Oracle OCP(12):ROLLUP & CUBEOracle
- Oracle OCP(48):UNDO TABLESPACEOracle
- Oracle OCP(58):ARCHIVELOG 管理OracleHive