131. Which view would you use to display the column names and DEFAULT values
for a table?
A. DBA_TABLES
B. DBA_COLUMNS
C. USER_COLUMNS
D. USER_TAB_COLUMNS
Answer: D
SELECT COLUMN_NAME,
DECODE(DATA_TYPE,'DATE' , DATA_TYPE ,'NUMBER' , DATA_TYPE ||
DECODE(DATA_SCALE,NULL,NULL,'(' || DATA_PRECISION || ',' || DATA_SCALE ||
')'),'VARCHAR2', DATA_TYPE || '(' || DATA_LENGTH || ')', NULL)DATA_TYPE
FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'INVOICES';
132. View the Exhibit and examine the structure for the ORDERS and ORDER_ITEMS
tables.You want to display ORDER_ID, PRODUCT_ID, and TOTAL (UNIT_PRICE
multiplied by QUANTITY) for all the orders placed in the last seven days.
Which query would you execute?
A. SELECT order_id, product_id, unit_price*quantity "TOTAL"
FROM order_items oi JOIN orders o
ON (o.order_id=oi.order_id)
WHERE o.order_date>=SYSDATE-7
B. SELECT o.order_id,oi.product_id, oi.unit_price*oi.quantity "TOTAL"
FROM order_items oi JOIN orders o
USING (order_id)
WHERE o.order_date>=SYSDATE-7
C. SELECT o.order_id, oi.product_id, oi.unit_price*oi.quantity "TOTAL"
FROM order_items oi JOIN orders o
WHERE o.order_date>=SYSDATE-7
ON (o.order_id=oi.order_id).
D. SELECT o.order_id, oi.product_id, oi.unit_price*oi.quantity "TOTAL"
FROM order_items oi JOIN orders o
ON (o.order_id=oi.order_id)
WHERE o.order_date>=SYSDATE-7
answer:D
USING里面的内容不能在select里面出现
133. Which three statements are true? (Choose three.)
A. Only one LONG column can be used per table.
B. A TIMESTAMP data type column stores only time values with fractional
seconds.
C. The BLOB data type column is used to store binary data in an operating
system file.
D. The minimum column width that can be specified for a varchar2 data type
column is one.
E. The value for a CHAR data type column is blank padded
Answer: ADE
Fractional:小数 blankpadded:估计是补空格的意思
The CHAR(n) datatype pads any remaining unused space with blanks to ensure that
the length of your value will always equal the value of n.
Oracle 将lob 分类为两种:
1.存储在数据库里的,参与数据库的事务。BLOB,CLOB,NCCLOB。
2.存储在数据库外的BFILE,不参与数据库的事务,也就是不能rollback 或commit 等,它依
赖于文件系统的数据完整性。
BFILE 二进制文件,存储在数据库外的操作系统文件,只读的。把此文件当二进制处理。
BLOB 二进制大对象。存储在数据库里的大对象,一般是图像声音等文件。
CLOB 字符型大对象。一般存储大数量文本信息。存储单字节,固定宽度的数据。
NCLOB 字节字符大对象。存储单字节大块,多字节固定宽度,多字节变宽度数据。
The BFILE data type enables access to binary file LOBs that are stored in file systems
outside Oracle Database. A BFILE column or attribute stores a BFILE locator, which
serves as a pointer to a binary file on the server file system. The locator maintains
the directory name and the filename.
134. Which two statements are true regarding subqueries? (Choose two.)
A. Only two subqueries can be placed at one level.
B. A subquery can be used to access data from one or more tables or views.
C. If the subquery returns 0 rows, then the value returned by the subquery
expression is NULL.
D. The columns in a subquery must always be qualified with the name or alias
of the table used.
E. A subquery in the WHERE clause of a SELECT statement can be nested up to
three levels only.
Answer: BC
Qualify:限制
SQL> select decode((select revenue from test where dest='dd'),null,11) dest
from test;
DEST
----------
11
说明如果子查询返回0行,则整个返回值为空
135. View the Exhibit and examine the description of the PRODUCT_INFORMATION
table.SELECT product_name, list_price, min_price, list_price-min_price
Difference FROM product_information
Which options when used with the above SQL statement can produce the sorted
output in ascending order of the price difference between LIST_PRICE and
MIN_PRICE? (Choose all that apply.)
A. ORDER BY 4
B. ORDER BY MIN_PRICE
C. ORDER BY DIFFERENCE
D. ORDER BY LIST_PRICE
E. ORDER BY LIST_PRICE -MIN_PRICE
Answer: ACE
ORDER BY可以用别名
136. Evaluate the following statement:
INSERT ALL
WHEN order_total < 10000 THEN
INTO small_orders
WHEN order_total > 10000 AND order_total < 20000 THEN
INTO medium_orders
WHEN order_total > 2000000 THEN
INTO large_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 the WHEN clauses are true.
Answer: A
INSERT ALL 所有条件都要访问一遍
Evaluate:求..值 regardless:不管
137. Which three possible values can be set for the TIME_ZONE session
parameter by using the ALTER SESSION command? (Choose three.)
A. 'os'
B. local
C. '-8:00'
D. dbtimezone
E. 'Australia'
Answer: BCD
E选项不是时区
The session time zone can be set to:
- O/S local time zone
- Database time zone
- An absolute offset
- A named region
1. The first method consists to use one of the following ALTER SESSION SET
TIME_ZONE statements:
SQL> ALTER SESSION SET TIME_ZONE = local;
SQL> ALTER SESSION SET TIME_ZONE = dbtimezone;
SQL> ALTER SESSION SET TIME_ZONE = '-05:00';
SQL> ALTER SESSION SET TIME_ZONE = 'Europe/London';
138. View the Exhibit and examine the structure of the ORDER_ITEMS table.
Examine the following SQL statement:
SELECT order_id, product_id, unit_price
FROM order_items WHERE unit_price = (SELECT MAX(unit_price)
FROM order_items GROUP BY order_id).
You want to display the PRODUCT_ID of the product that has the highest
UNIT_PRICE per ORDER_ID.
What correction should be made in the above SQL statement to achieve this?
A. Replace = with the IN operator.
B. Replace = with the >ANY operator.
C. Replace = with the >ALL operator.
D. Remove the GROUP BY clause from the subquery and place it in the main query.
Answer: A
SELECT MAX(unit_price) FROM order_items GROUP BY order_id 会按order_id
返回多条记录
需试验
139. View the Exhibit and examine the table structure of DEPARTMENTS and
LOCATIONS tables.You want to display all the cities that have no departments
and the departments that have not been allocated cities.
Which type of join between DEPARTMENTS and LOCATIONS tables would produce
this information as part of its output?
A. NATURAL JOIN
B. FULL OUTER JOIN
C. LEFT OUTER JOIN
D. RIGHT OUTER JOIN
Answer: B
If we want to combine the effects of a RIGHT OUTER JOIN and LEFT OUTER
JOIN together, we can use the FULL OUTER JOIN
141. View the Exhibit and examine the descriptions for ORDERS and ORDER_ITEMS
tables.Evaluate the following SQL statement:
SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity) "Order
Amount" FROM order_items oi JOIN orders o
ON oi.order_id = o.order_id
GROUP BY CUBE (o.customer_id, oi.product_id);
Which three statements are true regarding the output of this SQL statement?
(Choose three.)
A. It would return the subtotals for the Order Amount of every CUSTOMER_ID.
B. It would return the subtotals for the Order Amount for every PRODUCT_ID.
C. It would return the subtotals for the Order Amount of every PRODUCT_ID
and CUSTOMER_ID as one group.
D. It would return the subtotals for the Order Amount of every CUSTOMER_ID
and PRODUCT_ID as one group.
E. It would return only the grand total for the Order Amount of every
CUSTOMER_ID and PRODUCT_ID as one group.
Answer: ABD
142. In which scenario would you use the ROLLUP operator for expression or
columns within a GROUP BY clause?
A. to find the groups forming the subtotal in a row
B. to create groupwise grand totals for the groups specified within a GROUP
BY clause
C. to create a grouping for expressions or columns specified within a GROUP
BY clause in one direction,from right to left for calculating the subtotals
D. to create a grouping for expressions or columns specified within a GROUP
BY clause in all possible directions, which is crosstabular report for
calculating the subtotals
Answer: C
Calculat:计算
144. View the Exhibit and examine the details of the EMPLOYEES table.
You want to generate a hierarchical report for all the employees who report
to the employee whose
EMPLOYEE_ID is 100.
Which SQL clauses would you require to accomplish the task? (Choose all that
apply.)
A. WHERE
B. HAVING
C. GROUP BY
D. START WITH
E. CONNECT BY
Answer: ADE
145. View the Exhibit and examine the description of the EMPLOYEES table.
Evaluate the following SQL statement:
SELECT first_name, employee_id, NEXT_DAY(ADD_MONTHS(hire_date, 6), 1)
"Review" FROM employees;The query was written to retrieve the FIRST_NAME,
EMPLOYEE_ID, and review date for employees.The review date is the first
Monday after the completion of six months of the hiring. The
NLS_TERRITORY parameter is set to AMERICA in the session.
Which statement is true regarding this query?
A. The query would execute to give the desired output.
B. The query would not execute because date functions cannot be nested.
C. The query would execute but the output would give review dates that are
Sundays.
D. The query would not execute because the NEXT_DAY function accepts a string
as argument.
Answer: C
NEXT_DAY的第2个参数可以是数字1-7,分别表示周日到周六
例如取下一个星期六 select next_day(sysdate,7) FROM DUAL;
146. Which statement correctly differentiates a system privilege from an
object privilege?
A. System privileges can be granted only by the DBA whereas object privileges
can be granted by DBAs or the owner of the object.
B. System privileges give the rights to only create user schemas whereas
object privileges give rights to manipulate objects in a schema.
C. Users require system privileges to gain access to the database whereas
they require object privileges to create objects in the database.
D. A system privilege is the right to perform specific activities in a
database where as an object privilege is a right to perform activities on
a specific object in the database.
Answer: D
147. View the Exhibit and examine the description of the ORDERS table.
Your manager asked you to get the SALES_REP_ID and the total numbers of orders
placed by each of the sales representatives. Which statement would provide
the desired result?
A. SELECT sales_rep_id, COUNT(order_id) total_orders
FROM orders GROUP BY sales_rep_id;
B. SELECT sales_rep_id, COUNT(order_id) total_orders
FROM orders GROUP BY sales_rep_id, total_orders;
C. SELECT sales_rep_id, COUNT(order_id) total_orders
FROM orders;
D. SELECT sales_rep_id, COUNT(order_id) total_orders
FROM orders
WHERE sales_rep_id IS NOT NULL;
Answer: A
Representative:代表
150. Which statements are true regarding the hierarchical query in Oracle
Database 10g? (Choose all thatapply.)
A. It is possible to retrieve data only in topdown hierarchy.
B. It is possible to retrieve data in topdown or bottomup hierarchy.
C. It is possible to remove an entire branch from the output of the
hierarchical query.
D. You cannot specify conditions when you retrieve data by using a
hierarchical query.
Answer: BC
151. View the Exhibit and examine the structure of ORDERS and CUSTOMERS
tables.Which INSERT statement should be used to add a row into the ORDERS
table for the customer whose CUST_LAST_NAME is Roberts and CREDIT_LIMIT is
600?
A. INSERT INTO orders VALUES (1,'10mar2007','direct',
(SELECT customer_id FROM customers
WHERE cust_last_name='Roberts' AND credit_limit=600), 1000);
B. INSERT INTO orders (order_id,order_date,order_mode,
(SELECT customer_id FROM customers WHERE cust_last_name='Roberts' AND
credit_limit=600),order_total)
VALUES(1,'10mar2007','direct',&&customer_id, 1000);
C. INSERT INTO orders (order_id,order_date,order_mode,
(SELECT customer_id FROM customers
WHERE cust_last_name='Roberts' AND credit_limit=600),order_total)
VALUES(1,'10mar2007','direct', &customer_id, 1000);
D. INSERT INTO(SELECT o.order_id, o.order_date,o.order_mode,c.customer_id,
o.order_total FROM orders o, customers c
WHERE o.customer_id = c.customer_id
AND c.cust_last_name='Roberts' AND c.credit_limit=600 )
VALUES (1,'10mar2007','direct',(SELECT customer_id
FROM customers WHERE cust_last_name='Roberts' AND
credit_limit=600), 1000);
Answer: A
Eg: insert into dept values(6,4,(select ename from emp where emp_No=5));
152. Evaluate the following SQL statement:
SELECT product_name || 'it's not available for order'
FROM product_information WHERE product_status = 'obsolete';
You received the following error while executing the above query:
ERROR:ORA-01756:quoted string not properly terminated
What would you do to execute the query successfully?
A. Enclose the character literal string in the SELECT clause within the double
quotation marks.
B. Do not enclose the character literal string in the SELECT clause within
the single quotation marks.
C. Use Quote (q) operator and delimiter to allow the use of single quotation
mark in the literal character string.
D. Use escape character to negate the single quotation mark inside the literal
character string in the SELECT clause.
Answer: C
Quote:引用 delimiter:分隔符 literal:文字的
在Oracle中
双引号的作用是:如果创建对象的时候,对象名、字段名加双引号,则表示Oracle
将严格区分大小写,否则Oracl都默认大写;双引号一般是用来转义的,如果alias
里面有空格或其它保留符号,必须使用双引号。
而单引号则表示:这个加了单引号的字段是一个字类似字符串,并不区分大小写;
单引号是用来特制的,比如字符串的引用,日期字符串的引用,都必须包括在单引
号中,可以参与运算或其它表达式中。两者不可混用,其中,两个单引号可以作为
单引号的转义使用,意思就是一个真正的、没有特殊功能的单引号。例如 select
substr('I''am a pig',1,4)。
oracle字符串是不可以用双引号的,你嵌套的话只能用单引号,转义一下就可以
了,连续两个单引号表示转义.
Eg: select name||'I''m diandian' from dept;
153. Which statement correctly grants a system privilege?
A. GRANT EXECUTE ON proc1 TO PUBLIC;
B. GRANT CREATE VIEW ON table1 TO user1;
C. GRANT CREATE TABLE TO user1,user2;
D. GRANT CREATE SESSION TO ALL;
Answer: C
Eg: SQL>GRANT CREATE TABLE,CREATE VIEW TO USER1,USER2 WITH ADMIN OPTION
158. The first DROP operation is performed on PRODUCTS table using the
following command:
DROP TABLE products PURGE;
Then you performed the FLASHBACK operation by using the following command:
FLASHBACK TABLE products TO BEFORE DROP;
Which statement describes the outcome of the FLASHBACK command?
A. It recovers only the table structure.
B. It recovers the table structure, data, and the indexes.
C. It recovers the table structure and data but not the related indexes.
D. It is not possible to recover the table structure, data, or the related
indexes.
Answer: D
看题仔细,后面有purge
159. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS
tables.Evaluate the following SQL statement:
SELECT oi.order_id, product_id, order_date
FROM order_items oi JOIN orders o USING(order_id);
Which statement is true regarding the execution of this SQL statement?
A. The statement would not execute because table aliases are not allowed in
the JOIN clause.
B. The statement would not execute because the table alias prefix is not used
in the USING clause.
C. The statement would not execute because all the columns in the SELECT
clause are not prefixed with table aliases.
D. The statement would not execute because the column part of the USING clause
cannot have a qualifier in the SELECT list.
Answer: D
Eg:
1:create table order_items(order_id number(12),line_item_id number(3),product_id
number(6));
create table orders(order_id number(12),order_date timestamp(6) with local time zone);
2:insert into order_items values(1,100,1000);
insert into orders values(1,to_timestamp ('2010/01/09 14:51:21','yyyy/mm/dd
hh24:mi:ss'));
3: USING 子句的列部分不能有限定词
select o.order_id,product_id,order_date
from order_items oi join orders o
using(order_id);
ORA-25154: USING 子句的列部分不能有限定词
4:using子句里也不能有限定词
select order_id,product_id,order_date
from order_items oi left join orders o
using(oi.order_id);
ORA-01748: 此处只允许简单的列名
5: ok (不在using里可以用)
select order_id,oi.product_id,order_date
from order_items oi join orders o
using(order_id);
6: ok
select order_id,product_id,order_date
from order_items oi join orders o
using(order_id);
7:ok 类似natural join
select order_id,oi.product_id,order_date
from order_items oi natural join orders o;
The keyword USING is similar to the natural join, in the sense that its
use depends on the presence of identically named columns in the JOIN.
No table name prefix is allowed before the column name,not here, and not
elsewhere in the statement,The USING keyword does basically the same thing
as the natural join in the sense that the connection between the joined tables
is performed automatically. The difference is that USING lets us perform an
outer join as well as an inner join.
160. Which statement is true regarding synonyms?
A. Synonyms can be created for tables but not views.
B. Synonyms are used to reference only those tables that are owned by another
user.
C. A public synonym and a private synonym can exist with the same name for
the same table.
D. The DROP SYNONYM statement removes the synonym, and the status of the table
on which the synonym has been created becomes invalid.
Answer:C
161. View the Exhibit and examine the data in EMPLOYEES and DEPARTMENTS tables.
In the EMPLOYEES table EMPLOYEE_ID is the PRIMARY KEY and DEPARTMENT_ID is
the FOREIGN KEY. In the DEPARTMENTS table DEPARTMENT_ID is the PRIMARY KEY.
Evaluate the following UPDATE statement:
UPDATE employees a SET department_id =
(SELECT department_id
FROM departments
WHERE location_id = '2100'),
(salary, commission_pct) =
(SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct)
FROM employees b
WHERE a.department_id = b.department_id)
WHERE first_name||' '||last_name = 'Amit Banda';
What would be the outcome of the above statement?
A. It would execute successfully and update the relevant data.
B. It would not execute successfully because there is no LOCATION_ID 2100
in the DEPARTMENTS table.
C. It would not execute successfully because the condition specified with
the concatenation operator is not valid.
D. It would not execute successfully because multiple columns
(SALARY,COMMISSION_PCT)cannot be used in an UPDATE statement.
Answer: A
Eg:update dept a set deptid=
(select max(emp_no) from emp
where mgr_no=4),
paredeptid=(select avg(salary) from emp b
where a.deptid=b.emp_no)
where trim(name)||' '||trim(name)='1ee 1ee';
162. 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, the
DEPARTMENT_ID column has value 30, and the SALARY column has a value greater
than 3,000. Which SQL statement would get you the desired result?
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;
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);
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;
D. SELECT employee_id, first_name
FROM employees WHERE (job_id like '%MAN' OR job_id like '%CLERK' )
AND department_id = 30 AND salary > 3000;
Answer: D
163. View the Exhibit and examine the structure of ORD and ORD_ITEMS tables.
In the ORD table, the PRIMARY KEY is ORD_NO and in the ORD_ITEMS tables the
composite PRIMARY KEY is (ORD_NO, ITEM_NO).
Which two CREATE INDEX statements are valid? (Choose two.)
A. CREATE INDEX ord_idx ON ord(ord_no);
B. CREATE INDEX ord_idx ON ord_items(ord_no);
C. CREATE INDEX ord_idx ON ord_items(item_no);
D. CREATE INDEX ord_idx ON ord,ord_items(ord_no, ord_date,qty);
Answer: BC
164. View the Exhibit and examine the structure of the LOCATIONS and
DEPARTMENTS tables.Which SET operator should be used in the blank space in
the following SQL statement to display the cities that have departments
located in them?
SELECT location_id, city
FROM locations
____
SELECT location_id, city
FROM locations JOIN departments
USING(location_id);
A. UNION
B. MINUS
C. INTERSECT
D. UNION ALL
Answer: C
165. 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.
B. Statement 2 by user HR would not work because the grant is only for SELECT
in a subquery of update.
C. There are no errors in the statements issued by OE and HR; all the statements
would execute successfully.
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.
Answer: C
166. Evaluate the following SQL statements that are issued in the given order:
CREATE TABLE emp
(emp_no NUMBER(2) CONSTRAINT emp_emp_no_pk PRIMARY KEY,
ename VARCHAR2(15),salary NUMBER(8,2),
mgr_no NUMBER(2) CONSTRAINT emp_mgr_fk REFERENCES emp);
ALTER TABLE emp DISABLE CONSTRAINT emp_emp_no_pk CASCADE;
ALTER TABLE emp ENABLE CONSTRAINT emp_emp_no_pk;
What would be the status of the foreign key EMP_MGR_FK?
A. It would be automatically enabled and deferred.
B. It would be automatically enabled and immediate.
C. It would remain disabled and has to be enabled manually using the ALTER
TABLE command.
D. It would remain disabled and can be enabled only by dropping the foreign
key constraint and recreating it.
Answer: C
167. View the Exhibit and examine the description of the ORDERS table.
You need to display CUSTOMER_ID for all customers who have placed orders more
than three times in the last six months. You issued the following SQL
statement:
SELECT customer_id,COUNT(order_id)
FROM orders WHERE COUNT(order_id)>3 AND
order_date BETWEEN ADD_MONTHS(SYSDATE,6) AND SYSDATE
GROUP BY customer_id;
Which statement is true regarding the execution of the above statement?
A. It would execute successfully and provide the desired result.
B. It would not execute because the WHERE clause cannot have an aggregate
function.
C. It would not execute because the ORDER_ID column is not included in the
GROUP BY clause.
D. It would not execute because the GROUP BY clause should be placed before
the WHERE clause.
Answer: B
Where 条件里不能带合计函数,可以用having来求和
168. Given below are the SQL statements executed in a user session:
CREATE TABLE product(pcode NUMBER(2),pname VARCHAR2(10));
INSERT INTO product VALUES(1, 'pen');
INSERT INTO product VALUES(2,'pencil');
SAVEPOINT a;
UPDATE product SET pcode = 10 WHERE pcode = 1;
SAVEPOINT b;
DELETE FROM product WHERE pcode = 2;
COMMIT;
DELETE FROM product WHERE pcode=10;
ROLLBACK TO SAVEPOINT a;
Which statement describes the consequences?
A. No SQL statement would be rolled back.
B. Both the DELETE statements would be rolled back.
C. Only the second DELETE statement would be rolled back.
D. Both the DELETE statements and the UPDATE statement would be rolled back.
Answer: A
169. Evaluate the following SQL statement:
ALTER TABLE hr.emp SET UNUSED (mgr_id);
Which statement is true regarding the effect of the above SQL statement?
A. Any synonym existing on the EMP table would have to be recreated.
B. Any constraints defined on the MGR_ID column would be removed by the above
command.
C. Any views created on the EMP table that include the MGR_ID column would
have to be dropped and recreated.
D. Any index created on the MGR_ID column would continue to exist until the
DROP UNUSED COLUMNS command is executed.
Answer: B
170. The details of the order ID, order date, order total, and customer ID
are obtained from the ORDERS table. If the order value is more than 30000,
the details have to be added to the LARGE_ORDERS table.The order ID, order
date, and order total should be added to the ORDER_HISTORY table, and order
ID and customer ID should be added to the CUST_HISTORY table. Which multitable
INSERT statement would you use?
A. Pivoting INSERT
B. Unconditional INSERT
C. Conditional ALL INSERT
D. Conditional FIRST INSERT
Answer: C
171. View the Exhibit and examine the structure of the EMPLOYEES table.
Evaluate the following SQL statement:
SELECT employee_id, last_name, job_id, manager_id
FROM employees START WITH employee_id = 101
CONNECT BY PRIOR employee_id=manager_id;
Which statement is true regarding the output for this command?
A. It would return a hierarchical output starting with the employee whose
EMPLOYEE_ID is 101, followed by his or her peers.
B. It would return a hierarchical output starting with the employee whose
EMPLOYEE_ID is 101, followed by the employee to whom he or she reports.
C. It would return a hierarchical output starting with the employee whose
EMPLOYEE_ID is 101,followed by employees below him or her in the hierarchy.
D. It would return a hierarchical output starting with the employee whose
EMPLOYEE_ID is101, followed by employees up to one level below him or her
in the hierarchy.
Peer:同等
Answer: C
PRIOR 在的那边是父节点
172. View the Exhibit and examine the structure of the ORDERS table.
NEW_ORDERS is a new table with the columns ORD_ID, ORD_DATE, CUST_ID, and
ORD_TOTAL that have the same data types and size as the corresponding columns
in the ORDERS table.Evaluate the following INSERT statement:
INSERT INTO new_orders (ord_id, ord_date, cust_id, ord_total)
VALUES(SELECT order_id,order_date,customer_id,order_total
FROM orders WHERE order_date > '31dec1999');
Why would the INSERT statement fail?
A. because column names in NEW_ORDERS and ORDERS tables do not match
B. because the VALUES clause cannot be used in an INSERT with a subquery
C. because the WHERE clause cannot be used in a subquery embedded in an INSERT
statement
D. because the total number of columns in the NEW_ORDERS table does not match
the total number of columns in the ORDERS table
Answer: B
173. View the Exhibit1 and examine the descriptions of the EMPLOYEES and
DEPARTMENTS tables.The following SQL statement was executed:
SELECT e.department_id, e.job_id, d.location_id, sum(e.salary) total,
GROUPING(e.department_id) GRP_DEPT,GROUPING(e.job_id) GRP_JOB,
GROUPING(d.location_id) GRP_LOC FROM employees e JOIN departments d
ON e.department_id = d.department_id
GROUP BY ROLLUP (e.department_id, e.job_id, d.location_id);
View the Exhibit2 and examine the output of the command.
Which two statements are true regarding the output? (Choose two.)
A. The value 1 in GRP_LOC means that the LOCATION_ID column is taken into
account to generate the subtotal.
B. The value 1 in GRP_JOB and GRP_LOC means that JOB_ID and LOCATION_ID
columns are not taken into account to generate the subtotal.
C. The value 1 in GRP_JOB and GRP_LOC means that the NULL value in JOB_ID
and LOCATION_ID columns are taken into account to generate the subtotal.
D. The value 0 in GRP_DEPT, GRP_JOB, and GRP_LOC means that DEPARTMENT_ID,
JOB_ID, and LOCATION_ID columns are taken into account to generate the
subtotal.
Answer: BD
174. View the Exhibit and examine the structure of ORDERS and CUSTOMERS
tables.Evaluate the following UPDATE statement:
UPDATE(SELECT order_date, order_total, customer_id
FROM orders)SET order_date = '22mar2007'
WHERE customer_id =(SELECT customer_id
FROM customers WHERE cust_last_name = 'Roberts' AND credit_limit = 600);
Which statement is true regarding the execution of the above UPDATE
statement?
A. It would not execute because two tables cannot be used in a single UPDATE
statement.
B. It would execute and restrict modifications to only the columns specified
in the SELECT statement.
C. It would not execute because a subquery cannot be used in the WHERE clause
of an UPDATE statement.
D. It would not execute because the SELECT statement cannot be used in place
of the table name.
Answer: B
175. View the Exhibit and examine the data in the PRODUCTS table.
Which statement would add a column called PRICE, which cannot contain NULL?
A. ALTER TABLE products ADD price NUMBER(8,2) NOT NULL;
B. ALTER TABLE products ADD price NUMBER(8,2) DEFAULT NOT NULL;
C. ALTER TABLE products ADD price NUMBER(8,2) DEFAULT 0 NOT NULL;
D. ALTER TABLE products ADD price NUMBER(8,2) DEFAULT CONSTRAINT p_nn NOT
NULL;
Answer: C
Eg:在test表已经有数据的情况下
1: SQL> alter table test add C number(8,2) default 0 not null;
查询可以发现C列值全为0
2: SQL> alter table test add D number(8,2) not null;
ORA-01758: 要添加必需的 (NOT NULL) 列, 则表必须为空
176. Which three possible values can be set for the TIME_ZONE session
parameter by using the ALTER
SESSION command? (Choose three.)
A. 'os'
B. local
C. '8:00'
D. dbtimezone
E. 'Australia'
Answer: BCD
177. View the Exhibit and examine the structure of the ORD table.
Evaluate the following SQL statements that are executed in a user session
in the specified order:
CREATE SEQUENCE ord_seq;
SELECT ord_seq.nextval FROM dual;
INSERT INTO ord VALUES (ord_seq.CURRVAL, '25jan2007',101);
UPDATE ord SET ord_no= ord_seq.NEXTVAL WHERE cust_id =101;
What would be the outcome of the above statements?
A. All the statements would execute successfully and the ORD_NO column would
contain the value 2 for the CUST_ID 101.
B. The CREATE SEQUENCE command would not execute because the minimum value
and maximum value for the sequence have not been specified.
C. The CREATE SEQUENCE command would not execute because the starting value
of the sequence and the increment value have not been specified.
D. All the statements would execute successfully and the ORD_NO column would
have the value 20 for the CUST_ID 101 because the default CACHE value is 20.
Answer: A
SQL> create sequence ord_seq;
SQL> select ord_seq.currval from dual;
ORA-08002: 序列 ORD_SEQ.CURRVAL 尚未在此会话中定义
SQL> select ord_seq.nextval from dual;
1
SQL> select ord_seq.currval from dual;
1
180. ORD is a private synonym for the OE.ORDERS table.
The user OE issues the following command:
DROP SYNONYM ord;
Which statement is true regarding the above SQL statement?
A. Only the synonym would be dropped.
B. The synonym would be dropped and the corresponding table would become
invalid.
C. The synonym would be dropped and the packages referring to the synonym
would be dropped.
D. The synonym would be dropped and any PUBLIC synonym with the same name
becomes invalid.
Answer: A
182. View the Exhibit and examine the structure of the ORDERS table.
Which task would require subqueries?
A. displaying the total order value for sales representatives 161 and 163
B. displaying the order total for sales representative 161 in the year 1999
C. displaying the number of orders that have order mode online and order date
in 1999
D. displaying the number of orders whose order total is more than the average
order total for all online Orders
Answer: D
快速法:求平均值必需用到子查询计算
183. View the Exhibit and examine the structure of the EMP table which is
not partitioned and not an indexorganized table.
Evaluate the following SQL statement:
ALTER TABLE emp DROP COLUMN first_name;
Which two statements are true regarding the above command? (Choose two.)
A. The FIRST_NAME column would be dropped provided it does not contain any
data.
B. The FIRST_NAME column would be dropped provided at least one or more
columns remain in the table.
C. The FIRST_NAME column can be rolled back provided the SET UNUSED option
is added to the above SQL statement.
D. The FIRST_NAME column can be dropped even if it is part of a composite
PRIMARY KEY provided
the CASCADE option is used.
Answer: BD
1:sys用户下的表不能删除列的
ORA-12988: 无法删除属于 SYS 的表中的列
2:用admin用户登陆
create table test(a int primary key ,b int);
3: insert into test values(1,1);
4: alter table test drop column a;
说明即使是主键也可以删除
5: alter table test drop column b;
ORA-12983: 无法删除表的全部列,至少留一列吧!
184. View the Exhibit and examine the table structure of DEPARTMENTS and
LOCATIONS tables.You want to display all the cities that have no departments
and the departments that have not been allocated cities.Which type of join
between DEPARTMENTS and LOCATIONS tables would produce this information as
part of its output?
A. NATURAL JOIN
B. FULL OUTER JOIN
C. LEFT OUTER JOIN
D. RIGHT OUTER JOIN
Answer: B
185. View the Exhibit and examine the ORDERS table.
The ORDERS table contains data and all orders have been assigned a customer
ID. Which statement would add a NOT NULL constraint to the CUSTOMER_ID column?
A. ALTER TABLE orders ADD CONSTRAINT orders_cust_id_nn NOT NULL
(customer_id);
B. ALTER TABLE orders MODIFY customer_id CONSTRAINT orders_cust_id_nn NOT
NULL;
C. ALTER TABLE orders MODIFY CONeSTRAINT orders_cust_id_nn NOT NULL
(customer_id);
D. ALTER TABLE orders ADD customer_id NUMBER(6)CONSTRAINT orders_cust_id_nn
NOT NULL;
Answer: B
186. Which statement is true regarding the CUBE operator in the GROUP BY
clause of a SQL statement?
A. It produces only aggregates for the groups specified in the GROUP BY
clause.
B. It finds all the NULL values in the superaggregates for the groups
specified in the GROUP BY clause.
C. It produces 2 n possible superaggregate combinations, if the n columns
and expressions are specified in the GROUP BY clause.
D. It produces n+1 possible superaggregate combinations, if the n columns
and expressions are specified
in the GROUP BY clause.
Answer: C
187. View the Exhibit and examine the details of the EMPLOYEES table.
Evaluate the following SQL statements:
Statement 1:
SELECT employee_id, last_name, job_id,
manager_id FROM employees
START WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id AND manager_id != 108 ;
Statement 2:
SELECT employee_id, last_name, job_id, manager_id
FROM employees
WHERE manager_id != 108
START WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id;
Which two statements are true regarding the above SQL statements? (Choose
two.)
A. Statement 2 would not execute because the WHERE clause condition is not
allowed in a statement that
has the START WITH clause.
B. The output for statement 1 would display the employee with MANAGER_ID 108
and all the employees
below him or her in the hierarchy.
C. The output of statement 1 would neither display the employee with
MANAGER_ID 108 nor any employee below him or her in the hierarchy.
D. The output for statement 2 would not display the employee with MANAGER_ID
108 but it would display all the employees below him or her in the hierarchy.
Answer: CD
188. Evaluate the following command:
CREATE TABLE employees
(employee_id NUMBER(2) PRIMARY KEY,last_name VARCHAR2(25) NOT NULL,
department_id NUMBER(2),job_id VARCHAR2(8),salary NUMBER(10,2));
You issue the following command to create a view that displays the IDs and
last names of the sales staff in the organization:
CREATE OR REPLACE VIEW sales_staff_vu AS
SELECT employee_id, last_name,job_id
FROM employees
WHERE job_id LIKE 'SA_%'
WITH CHECK OPTION;
Which statements are true regarding the above view? (Choose all that apply.)
A. It allows you to insert details of all new staff into the EMPLOYEES table.
B. It allows you to delete the details of the existing sales staff from the
EMPLOYEES table.
C. It allows you to update the job ids of the existing sales staff to any
other job id in the EMPLOYEES table.
D. It allows you to insert the IDs, last names and job ids of the sales staff
from the view if it is used in multitable INSERT statements.
Answer: BD
189. Which statements are correct regarding indexes? (Choose all that apply.)
A. When a table is dropped, the corresponding indexes are automatically
dropped.
B. For each DML operation performed, the corresponding indexes are
automatically updated.
C. Indexes should be created on columns that are frequently referenced as
part of an expression.
D. A nondeferrable PRIMARY KEY or UNIQUE KEY constraint in a table
automatically creates a unique index.
Answer: ABD
Expression:表达式
190. Which SQL statement would display the view names and definitions of all
the views owned by you?
A. SELECT view_name, text FROM user_view;
B. SELECT view_name, text FROM user_object ;
C. SELECT view_name, text FROM user_objects;
D. SELECT view_name, text FROM user_views;
Answer: D
1: You can check the data dictionary’s USER_OBJECTS view to determine the
status of any of your views, like this:
SELECT STATUS, OBJECT_TYPE, OBJECT_NAME
FROM USER_OBJECTS
WHERE STATUS = 'INVALID'
ORDER BY OBJECT_NAME;
In our case, the output is:
------- ------------------- ----------------
INVALID VIEW EMP_PHONE_BOOK
INVALID VIEW VW_EMPLOYEES
2: The data dictionary contains a lot of information about views, including
the query upon which the view is based, which can be found in the USER_VIEWS
view and its TEXT column. Here’s a query on the data dictionary that asks
for the query that was used to create the view VW_EMPLOYEES:
SELECT TEXT FROM USER_VIEWS WHERE VIEW_NAME = 'VW_EMPLOYEES';
192. Which CREATE TABLE statement is valid?
A. CREATE TABLE ord_details
(ord_no NUMBER(2) PRIMARY KEY,
item_no NUMBER(3) PRIMARY KEY,
ord_date date NOT NULL);
B. CREATE TABLE ord_details
(ord_no NUMBER(2) UNIQUE, NOT NULL,
item_no NUMBER(3),
ord_date date DEFAULT SYSDATE NOT NULL);
C. CREATE TABLE ord_details
(ord_no NUMBER(2) ,item_no NUMBER(3),
ord_date date DEFAULT NOT NULL,
CONSTRAINT ord_uq UNIQUE (ord_no),
CONSTRAINT ord_pk PRIMARY KEY (ord_no));
D. CREATE TABLE ord_details
(ord_no NUMBER(2),item_no NUMBER(3),
ord_date date DEFAULT SYSDATE NOT NULL,
CONSTRAINT ord_pk PRIMARY KEY (ord_no, item_no));
Answer: D
对应D选项,若把某列设为主键,则自动把该列改为非空
SQL> desc ord_details;
名称 是否为空? 类型
ORD_NO NOT NULL NUMBER(2)
ITEM_NO NOT NULL NUMBER(3)
ORD_DATE NOT NULL DATE
193. View the Exhibit and examine PRODUCTS and ORDER_ITEMS tables.
You executed the following query to display PRODUCT_NAME and the number of
times the product has been ordered:
SELECT p.product_name, i.item_cnt
FROM (SELECT product_id, COUNT (*) item_cnt FROM order_items
GROUP BY product_id) i RIGHT OUTER JOIN products p
ON i.product_id = p.product_id;
What would happen when the above statement is executed?
A. The statement would execute successfully to produce the required output.
B. The statement would not execute because inline views and outer joins cannot
be used together.
C. The statement would not execute because the ITEM_CNT alias cannot be
displayed in the outer query.
D. The statement would not execute because the GROUP BY clause cannot be used
in the inline view.
Answer: A
194. Evaluate the following CREATE TABLE command:
CREATE TABLE order_item
(order_id NUMBER(3),item_id NUMBER(2),
qty NUMBER(4),CONSTRAINT ord_itm_id_pk PRIMARY KEY (order_id,item_id)
USING INDEX (CREATE INDEX ord_itm_idx ON order_item(order_id,item_id)));
Which statement is true regarding the above SQL statement?
A. It would execute successfully and only ORD_ITM_IDX index would be created.
B. It would give an error because the USING INDEX clause cannot be used on
a composite primary key.
C. It would execute successfully and two indexes ORD_ITM_IDX and
ORD_ITM_ID_PK would be created.
D. It would give an error because the USING INDEX clause is not permitted
in the CREATE TABLE command.
Answer: A
195. View the Exhibit and examine the structure of ORDERS and ORDER_ITEMS
tables.ORDER_ID is the primary key in the ORDERS table. It is also the foreign
key in the ORDER_ITEMS table where in it is created with the ON DELETE CASCADE
option. Which DELETE statement would execute successfully?
A. DELETE order_id
FROM orders
WHERE order_total < 1000;
B. DELETE orders
WHERE order_total < 1000;
C. DELETE FROM orders
WHERE (SELECT order_id
FROM order_items);
D. DELETE orders o, order_items i
WHERE o.order_id = i.order_id;
Answer: B
198. OE and SCOTT are the users in the database. The ORDERS table is owned
by OE. Evaluate the statements issued by the DBA in the following sequence:
CREATE ROLE r1;
GRANT SELECT, INSERT ON oe.orders TO r1;
GRANT r1 TO scott;
GRANT SELECT ON oe.orders TO scott;
REVOKE SELECT ON oe.orders FROM scott;
What would be the outcome after executing the statements?
A. SCOTT would be able to query the OE.ORDERS table.
B. SCOTT would not be able to query the OE.ORDERS table.
C. The REVOKE statement would remove the SELECT privilege from SCOTT as well
as from the role R1.
D. The REVOKE statement would give an error because the SELECT privilege has
been granted to the role R1.
Answer: A
199. Evaluate the following CREATE SEQUENCE statement:
CREATE SEQUENCE seq1 START WITH 100
INCREMENT BY 10 MAXVALUE 200 CYCLE NOCACHE;
The sequence SEQ1 has generated numbers up to the maximum limit of 200. You
issue the following
SQL statement:
SELECT seq1.nextval FROM dual;
What is displayed by the SELECT statement?
A. 1
B. 10
C. 100
D. an error
Answer: A
200. SCOTT is a user in the database.
Evaluate the commands issued by the DBA:
1 CREATE ROLE mgr;
2 GRANT CREATE TABLE, SELECT ON oe.orders TO mgr;
3 GRANT mgr, create table TO SCOTT;
Which statement is true regarding the execution of the above commands?
A. Statement 1 would not execute because the WITH GRANT option is missing.
B. Statement 1 would not execute because the IDENTIFIED BY <password> clause
is missing.
C. Statement 3 would not execute because role and system privileges cannot
be granted together in a single GRANT statement.
D. Statement 2 would not execute because system privileges and object
privileges cannot be granted together in a single GRANT command.
Answer: D
Eg:
1: CREATE ROLE mgr; ok
2: GRANT CREATE TABLE, SELECT ON scott.detp TO mgr;
ORA-00990: 权限缺失或无效
系统和对象权限不能同时赋予角色
3: GRANT mgr, create table TO scott; ok
角色和对象权限能同时赋予用户
4: GRANT mgr, SELECT ON admin.detp TO scott;
ORA-00990: 权限缺失或无效
看来角色和对象权限也不能同时赋予用户
201. Evaluate the CREATE TABLE statement:
CREATE TABLE products
(product_id NUMBER(6) CONSTRAINT prod_id_pk PRIMARY KEY,
product_name VARCHAR2(15));
Which statement is true regarding the PROD_ID_PK constraint?
A. It would be created only if a unique index is manually created first.
B. It would be created and would use an automatically created unique index.
C. It would be created and would use an automatically created nonunique index.
D. It would be created and remains in a disabled state because no index is
specified in the command.
Answer: B
202. 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?
A. SELECT order_id FROM order_items
WHERE(unit_price*quantity) = MAX(unit_price*quantity) GROUP BY order_id;
B. SELECT order_id FROM order_items
WHERE(unit_price*quantity) = (SELECT MAX(unit_price*quantity)
FROM order_items) GROUP BY order_id;
C. SELECT order_id FROM order_items
WHERE (unit_price*quantity) = (SELECT MAX(unit_price*quantity)
FROM order_items GROUP BY order_id);
D. 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);
Answer: D
只有having才可以有求和计算
203. View the Exhibit button and examine the structures of ORDERS and
ORDER_ITEMS tables.In the ORDERS table, ORDER_ID is the PRIMARY KEY and in
the ORDER_ITEMS table, ORDER_ID and LINE_ITEM_ID form the composite primary
key.Which view can have all the DML operations performed on it?
A. CREATE VIEW V1 AS SELECT order_id, product_id
FROM order_items;
B. CREATE VIEW V4(or_no, or_date, cust_id) AS SELECT order_id, order_date,
customer_id FROM orders WHERE order_date < '30mar2007' WITH CHECK OPTION;
C. CREATE VIEW V3 AS SELECT o.order_id, o.customer_id, i.product_id
FROM orders o, order_items I WHERE o.order_id=i.order_id;
D. CREATE VIEW V2 AS SELECT order_id, line_item_id, unit_price*quantity
total FROM order_items;
Answer: B
Performed:执行
不明白
206. View the Exhibit and examine the details of the PRODUCT_INFORMATION
table.Evaluate the following SQL statement:
SELECT TO_CHAR(list_price,'$9,999') FROM product_information;
Which two statements would be true regarding the output for this SQL statement?
(Choose two.)
A. The LIST_PRICE column having value 1123.90 would be displayed as $1,124.
B. The LIST_PRICE column having value 1123.90 would be displayed as $1,123.
C. The LIST_PRICE column having value 11235.90 would be displayed as $1,123.
D. The LIST_PRICE column having value 11235.90 would be displayed as #######.
Answer: AD
Eg:create table test(a int,b number(8,2))
insert into test values(1,1123.90);
insert into test values(2,11235.90);
SELECT TO_CHAR(b,'$9,999') FROM test where a=1;
$1,124
SELECT TO_CHAR(b,'$9,999') FROM test where a=2;
#######
207. You executed the following SQL statements in the given order:
CREATE TABLE orders
(order_id NUMBER(3) PRIMARY KEY,order_date DATE, customer_id number(3));
INSERT INTO orders VALUES (100,'10mar2007',222);
ALTER TABLE orders MODIFY order_date NOT NULL;
UPDATE orders SET customer_id=333;
DELETE FROM order;
The DELETE statement results in the following error:
ERROR at line 1:
ORA00942:table or view does not exist
What would be the outcome?
A. All the statements before the DELETE statement would be rolled back.
B. All the statements before the DELETE statement would be implicitly
committed within the session.
C. All the statements up to the ALTER TABLE statement would be committed and
the outcome of UPDATE statement would be rolled back.
D. All the statements up to the ALTER TABLE statement would be committed and
the outcome of the UPDATE statement is retained uncommitted within the
session.
Answer: D
Statements:声明
ALTER TABLE 属于DDL语句,会隐式提交.
Remember that an ALTER TABLE statement is a DDL statement, and that when
any DDL statement executes, it causes an implied commit event to occur.
208. Which three tasks can be performed using regular expression support in
Oracle Database 10g?
(Choose three.)
A. It can be used to concatenate two strings.
B. It can be used to find out the total length of the string.
C. It can be used for string manipulation and searching operations.
D. It can be used to format the output for a column or expression having string
data.
E. It can be used to find and replace operations for a column or expression
having string data.
Answer: CDE
Manipulation:处理
210. View the Exhibit and examine the structure of the EMPLOYEES and
JOB_HISTORY tables. The query should display the employee IDs of all the
employees who have held the job SA_MAN at any time during their tenure.
Choose the correct SET operator to fill in the blank space and complete the
following query.
SELECT employee_id FROM employees WHERE job_id = 'SA_MAN'
____________
SELECT employee_id FROM job_history WHERE job_id='SA_MAN';
A. UNION
B. MINUS
C. INTERSECT
D. UNION ALL
Answer: A
Tenure:任期
211. The following are the steps for a correlated subquery, listed in random
order:
1) The WHERE clause of the outer query is evaluated.
2) The candidate row is fetched from the table specified in the outer query.
3) The procedure is repeated for the subsequent rows of the table, till all
the rows are processed.
4) Rows are returned by the inner query, after being evaluated with the value
from the candidate row in
the outer query.
Identify the option that contains the steps in the correct sequence in which
the Oracle server evaluates a
correlated subquery.
A. 4, 2, 1, 3
B. 4, 1, 2, 3
C. 2, 4, 1, 3
D. 2, 1, 4, 3
Answer: C
212. 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.
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.
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 <>.
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.
Answer: C
214. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS
tables.In the ORDERS table, ORDER_ID is the PRIMARY KEY and ORDER_DATE has
the DEFAULT value as SYSDATE.
Evaluate the following statement:
UPDATE orders SET order_date=DEFAULT
WHERE order_id IN (SELECT order_id FROM order_items
WHERE qty IS NULL);
What would be the outcome of the above statement?
A. The UPDATE statement would not work because the main query and the subquery
use different tables.
B. The UPDATE statement would not work because the DEFAULT value can be used
only in INSERT statements.
C. The UPDATE statement would change all ORDER_DATE values to SYSDATE
provided the current ORDER_DATE is NOT NULL and QTY is NULL.
D. The UPDATE statement would change all the ORDER_DATE values to SYSDATE
irrespective of what the current ORDER_DATE value is for all orders where
QTY is NULL.
Answer: D
Irrespective:不考虑的
215. View the Exhibit and examine the structure of the PRODUCT_INFORMATION
and INVENTORIES tables.You have a requirement from the supplies department
to give a list containing PRODUCT_ID,SUPPLIER_ID, and QUANTITY_ON_HAND for
all the products where in QUANTITY_ON_HAND is less than five.
Which two SQL statements can accomplish the task? (Choose two.)
A. SELECT product_id, quantity_on_hand , supplier_id
FROM product_information
NATURAL JOIN inventories AND quantity_on_hand < 5;
B. SELECT i.product_id, i.quantity_on_hand , pi.supplier_id
FROM product_information pi JOIN inventories i
USING (product_id) AND quantity_on_hand < 5;
C. SELECT i.product_id, i.quantity_on_hand , pi.supplier_id
FROM product_information pi JOIN inventories i
ON (pi.product_id=i.product_id) WHERE quantity_on_hand < 5;
D. SELECT i.product_id, i.quantity_on_hand , pi.supplier_id
FROM product_information pi JOIN inventories i
ON (pi.product_id=i.product_id) AND quantity_on_hand < 5;
Answer: CD
Eg:
1: select m.ename "Man",e.ename "Emp"
from emp m join emp e on m.emp_no=e.mgr_no where m.mgr_no=2;
2: select m.ename "Man",e.ename "Emp"
from emp m join emp e on m.emp_no=e.mgr_no and m.mgr_no=2;
218. Evaluate the following query:
SELECT INTERVAL '300' MONTH, INTERVAL '542' YEAR TO MONTH,
INTERVAL '11:12:10.1234567' HOUR TO SECOND FROM dual;
What is the correct output of the above query?
A. +25-00, +54-02,+00 11:12:10.123457
B. +00-300,+54-02,+00 11:12:10.123457
C. +25-00, +00-650,+00 11:12:10.123457
D. +00-300, +00-650,+00 11:12:10.123457
Answer: A
Eg:
1: SELECT INTERVAL'300'MONTH, INTERVAL'54-2'YEAR TO MONTH,
INTERVAL'11:12:10.1234567' HOUR TO SECOND FROM dual;
+25-00
+54-02
+00 11:12:10.123457
2: SQL> SELECT INTERVAL'24'MONTH from dual;
+02-00
3: SELECT INTERVAL'25'MONTH from dual;
+02-01
4:SELECT INTERVAL'54-12'year to month from dual;
SELECT INTERVAL'54-12'year to month from dual
ORA-01843: 无效的月份 (注:月份是0-11之间的数字)
221. You need to create a table for a banking application with the following
considerations:
1) You want a column in the table to store the duration of the credit period.
2) The data in the column should be stored in a format such that it can be
easily added and subtracted with
3) date type data without using the conversion functions.
4) The maximum period of the credit provision in the application is 30 days.
5) The interest has to be calculated for the number of days an individual
has taken a credit for.
Which data type would you use for such a column in the table?
A. INTERVAL YEAR TO MONTH
B. INTERVAL DAY TO SECOND
C. TIMESTAMP WITH TIME ZONE
D. TIMESTAMP WITH LOCAL TIME ZONE
Answer: B
要点:具体到天,不能用转换函数
223. View the Exhibit and examine the data in ORDERS and ORDER_ITEMS tables.
You need to create a view that displays the ORDER ID, ORDER_DATE, and the
total number of items in each order.
Which CREATE VIEW statement would create the view successfully?
A. CREATE OR REPLACE VIEW ord_vu (order_id,order_date)
AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)
"NO OF ITEMS"
FROM orders o JOIN order_items I ON (o.order_id = i.order_id)
GROUP BY o.order_id,o.order_date;
B. CREATE OR REPLACE VIEW ord_vu
AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)
"NO OF ITEMS"
FROM orders o JOIN order_items I ON (o.order_id = i.order_id)
GROUP BY o.order_id,o.order_date;
C. CREATE OR REPLACE VIEW ord_vu
AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)
FROM orders o JOIN order_items i
ON (o.order_id = i.order_id)
GROUP BY o.order_id,o.order_date;
D. CREATE OR REPLACE VIEW ord_vu
AS SELECT o.order_id, o.order_date, COUNT(i.line_item_id)||' NO OF ITEMS'
FROM orders o JOIN order_items i
ON (o.order_id = i.order_id)
GROUP BY o.order_id,o.order_date
WITH CHECK OPTION;
Answer: B
只有B定义了别名
1:SQL> create or replace view ord_vu as
select name ,count(paredeptid)
from dept
group by name;
ORA-00998: 必须使用列别名命名此表达式
2:SQL> create or replace view ord_vu as
select name ,count(paredeptid) "tt"
from dept
group by name;
视图已创建。
224. View the Exhibit and examine the description of the EMPLOYEES table.
Your company decided to give a monthly bonus of $50 to all the employees who
have completed five years in the company. The following statement is written
to display the LAST_NAME, DEPARTMENT_ID,and the total annual salary:
SELECT last_name, department_id, salary+50*12 "Annual Compensation"
FROM employees
WHERE MONTHS_BETWEEN(SYSDATE, hire_date)/12 >= 5;
When you execute the statement, the "Annual Compensation" is not computed
correctly. What changes
would you make to the query to calculate the annual compensation correctly?
A. Change the SELECT clause to SELECT last_name, department_id, salary*12+50
"Annual Compensation".
B. Change the SELECT clause to SELECT last_name, department_id,
salary+(50*12) "Annual Compensation".
C. Change the SELECT clause to SELECT last_name, department_id,
(salary+50)*12 "Annual Compensation".
D. Change the SELECT clause to SELECT last_name, department_id,
(salary*12)+50 "Annual Compensation".
Answer: C
a monthly bonus of $50是每个月加50
225. View the Exhibit and examine the descriptions of ORDER_ITEMS and ORDERS
tables.You want to display the CUSTOMER_ID, PRODUCT_ID, and total
(UNIT_PRICE multiplied by QUANTITY) for the order placed. You also want to
display the subtotals for a CUSTOMER_ID as well as for a PRODUCT_ID for the
last six months.Which SQL statement would you execute to get the desired
output?
A. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total" FROM order_items oi JOIN orders o ON oi.order_id=o.order_id
GROUP BY ROLLUP (o.customer_id,oi.product_id)
WHERE MONTHS_BETWEEN(order_date, SYSDATE) <= 6;
B. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total"FROM order_items oi JOIN orders o ON oi.order_id=o.order_id
GROUP BY ROLLUP (o.customer_id,oi.product_id)
HAVING MONTHS_BETWEEN(order_date, SYSDATE) <= 6;
C. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total"FROM order_items oi JOIN orders o
ON oi.order_id=o.order_id GROUP BY ROLLUP (o.customer_id, oi.product_id)
WHERE MONTHS_BETWEEN(order_date, SYSDATE) >= 6;
D. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total"FROM order_items oi JOIN orders o ON oi.order_id=o.order_id
WHERE MONTHS_BETWEEN(order_date, SYSDATE) <= 6
GROUP BY ROLLUP (o.customer_id, oi.product_id) ;
Answer: D
WHERE需在Group by前面
226. View the Exhibit and examine the structure of the EMPLOYEES table.
You want to retrieve hierarchical data of the employees using the topdown
hierarchy. Which SQL clause
would let you choose the direction to walk through the hierarchy tree?
A. WHERE
B. HAVING
C. GROUP BY
D. START WITH
E. CONNECT BY PRIOR
Answer: E
228. View the Exhibit and examine the description of the EMPLOYEES table.
You executed the following SQL statement:
SELECT first_name, department_id, salary
FROM employees ORDER BY department_id, first_name, salary desc;
Which two statements are true regarding the output of the above query? (Choose
two.)
A. The values in all the columns would be sorted in the descending order.
B. The values in the SALARY column would be sorted in descending order for
all the employees having the same value in the DEPARTMENT_ID column.
C. The values in the FIRST_NAME column would be sorted in ascending order
for all the employees having the same value in the DEPARTMENT_ID column.
D. The values in the FIRST_NAME column would be sorted in the descending order
for all the employees having the same value in the DEPARTMENT_ID column.
E. The values in the SALARY column would be sorted in descending order for
all the employees having the same value in the DEPARTMENT_ID and FIRST_NAME
column.
Answer: CE
试验证明Order by 有优先级的,排前面的优先级最高, 第一列排序完成后再按第二列指定顺序排序, 而且默认
是升序.但是试验结果表明对于union这种形式组织起来的数据不是完全是这样的,明确指出order by 的那列优
先级是最高的,而不是排前面的列优先级最高.
SQL> create table employees(first_name varchar(3),department_id varchar(3),salary varchar(3));
Sql>insert into employees values('1','1','1');
SQL> insert into employees values('1','2','3');
SQL> insert into employees values('1','3','2');
SQL> SELECT first_name, department_id, salary
FROM employees ORDER BY department_id, first_name, salary desc;
FIR DEP SAL (说明排前面的优先级高,这里没有顾及到第3列要求降序排列)
--- --- ---
1 1 1
1 2 3
1 3 2
SQL> update employees set department_id='1';
SQL> SELECT first_name, department_id, salary
2 FROM employees ORDER BY department_id, first_name, salary desc;
FIR DEP SAL
--- --- ---
1 1 3
1 1 2
1 1 1
SQL> update employees set first_name=salary;
SQL> SELECT first_name, department_id, salary
2 FROM employees ORDER BY department_id , first_name desc, salary;
FIR DEP SAL
--- --- ---
3 1 3
2 1 2
1 1 1
下面试验union聚集起来的数据order by情况
select 1,1,1
from dual
union
select 1,2,3
from dual
union
select 1,3,2
from dual
order by 3 desc;
(说明第3列要求降序排列优先级最高,而不是按排前面的列优先高来排序的,注意跟上面比较)
1 2 3
1 3 2
1 1 1
select 2,1,1
from dual
union
select 3,2,3
from dual
union
select 1,3,2
from dual
order by 2 desc,3 asc;
(说明第2列明确要求降序排列的优先级最高,而不是默认的第1列升序的优先级高)
1 3 2
3 2 3
2 1 1
select 2,1,1
from dual
union
select 3,2,3
from dual
union
select 1,3,2
from dual;
(在没有指明order by的前提下,这个时候按默认第一列升序排列,如果都相同,则按第2列升序)
1 3 2
2 1 1
3 2 3
229. EMPDET is an external table containing the columns EMPNO and ENAME. Which
command would work in relation to the EMPDET table?
A. UPDATE empdet
SET ename = 'Amit'
WHERE empno = 1234;
B. DELETE FROM empdet
WHERE ename LIKE 'J%';
C. CREATE VIEW empvu
AS SELECT * FROM empdept;
D. CREATE INDEX empdet_idx ON empdet(empno);
Answer: C
230. View the Exhibit and examine the descriptions of the DEPT and LOCATIONS
tables.You want to update the CITY column of the DEPT table for all the rows
with the corresponding value in the CITY column of the LOCATIONS table for
each department.Which SQL statement would you execute to accomplish the task?
A. UPDATE dept d
SET city = ANY (SELECT city FROM locations l);
B. UPDATE dept d
SET city = (SELECT city FROM locations l)
WHERE d.location_id = l.location_id;
C. UPDATE dept d
SET city = (SELECT city FROM locations l
WHERE d.location_id = l.location_id);
D. UPDATE dept d
SET city = ALL (SELECT city FROM locations l
WHERE d.location_id = l.location_id);
Answer: C
231. View the Exhibit and examine the description of the CUSTOMERS table.
You want to add a constraint on the CUST_FIRST_NAME column of the CUSTOMERS
table so that the value inserted in the column does not have numbers.
Which SQL statement would you use to accomplish the task?
A. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,'^AZ'))NOVALIDATE ;
B. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,'^[09]'))NOVALIDATE ;
C. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,'[[:alpha:]]'))NOVALIDATE ;
D. ALTER TABLE CUSTOMERS ADD CONSTRAINT cust_f_name
CHECK(REGEXP_LIKE(cust_first_name,'[[:digit:]]'))NOVALIDATE ;
Answer: C
232. 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.
B. It produces only the grand totals for the groups specified in the GROUP
BY clause.
C. It produces higherlevel subtotals, moving from right to left through the
list of grouping columns specified in the GROUP BY clause.
D. It produces higherlevel subtotals, moving in all the directions through
the list of grouping columns specified in the GROUP BY clause.
Answer: C
233. View the Exhibit and examine the description of EMPLOYEES and
DEPARTMENTS tables.You want to display the EMPLOYEE_ID, LAST_NAME, and
SALARY for the employees who get the maximum salary in their respective
departments. The following SQL statement was written:
WITH
SELECT employee_id, last_name, salary
FROM employees WHERE (department_id, salary) = ANY (SELECT *
FROM dept_max)dept_max as ( SELECT d.department_id, max(salary)
FROM departments d JOIN employees j ON (d.department_id = j.department_id)
GROUP BY d.department_id);
Which statement is true regarding the execution and the output of this
statement?
A. The statement would execute and give the desired results.
B. The statement would not execute because the = ANY comparison operator is
used instead of =.
C. The statement would not execute because the main query block uses the query
name before it is even created.
D. The statement would not execute because the comma is missing between the
main query block and the query name.
Answer: C
235. Evaluate the following CREATE TABLE commands:
CREATE TABLE orders
(ord_no NUMBER(2) CONSTRAINT ord_pk PRIMARY KEY,
ord_date DATE,cust_id NUMBER(4));
CREATE TABLE ord_items
(ord_no NUMBER(2),item_no NUMBER(3),
qty NUMBER(3) CHECK (qty BETWEEN 100 AND 200),
expiry_date date CHECK (expiry_date > SYSDATE),
CONSTRAINT it_pk PRIMARY KEY (ord_no,item_no),
CONSTRAINT ord_fk FOREIGN KEY(ord_no) REFERENCES orders(ord_no));
Why would the ORD_ITEMS table not get created?
A. SYSDATE cannot be used with the CHECK constraint.
B. The CHECK constraint cannot be used twice for the same table.
C. The BETWEEN clause cannot be used for the CHECK constraint.
D. ORD_NO and ITEM_NO cannot be used as a composite primary key because ORD_NO
is also the FOREIGN KEY.
Answer: A
238. View the Exhibit and examine the description of the EMPLOYEES table.
You want to display the EMPLOYEE_ID, FIRST_NAME, and DEPARTMENT_ID for all
the employees who work in the same department and have the same manager as
that of the employee having EMPLOYEE_ID 104. To accomplish the task, you
execute the following SQL statement:
SELECT employee_id, first_name, department_id FROM employees
WHERE (manager_id, department_id) =(SELECT department_id, manager_id
FROM employees WHERE employee_id = 104)
AND employee_id <> 104;
When you execute the statement it does not produce the desired output. What
is the reason for this?
A. The WHERE clause condition in the main query is using the = comparison
operator, instead of EXISTS.
B. The WHERE clause condition in the main query is using the = comparison
operator, instead of the IN operator.
C. The WHERE clause condition in the main query is using the = comparison
operator, instead of the = ANY operator.
D. The columns in the WHERE clause condition of the main query and the columns
selected in the subquery should be in the same order.
Answer: D
240. Which three statements are true regarding group functions? (Choose
three.)
A. They can be used on columns or expressions.
B. They can be passed as an argument to another group function.
C. They can be used only with a SQL statement that has the GROUP BY clause.
D. They can be used on only one column in the SELECT clause of a SQL statement.
E. They can be used along with the single row function in the SELECT clause
of a SQL statement.
Answer: ABE
single-row function指一行数据输入,返回一个值的函数。
如substr等。
而mutil-row function指多行数据输入,返回一个值的函数。
如sum、max等。
242. View the Exhibit and examine the structure of the CUST table.
Evaluate the following SQL statements executed in the given order:
ALTER TABLE cust ADD CONSTRAINT cust_id_pk PRIMARY KEY(cust_id) DEFERRABLE
INITIALLY DEFERRED;
INSERT INTO cust VALUES (1,'RAJ'); row 1
INSERT INTO cust VALUES (1,'SAM'); row 2
COMMIT;
SET CONSTRAINT cust_id_pk IMMEDIATE;
INSERT INTO cust VALUES (1,'LATA'); row 3
INSERT INTO cust VALUES (2,'KING'); row 4
COMMIT;
Which rows would be made permanent in the CUST table?
A. row 4 only
B. rows 2 and 4
C. rows 3 and 4
D. rows 1 and 4
Answer: C
243. View the Exhibit and examine the data in ORDERS_MASTER and
MONTHLY_ORDERS tables.Evaluate the following MERGE statement:
MERGE INTO orders_master o
USING monthly_orders m
ON (o.order_id = m.order_id)
WHEN MATCHED THEN
UPDATE SET o.order_total = m.order_total
DELETE WHERE (m.order_total IS NULL)
WHEN NOT MATCHED THEN
INSERT VALUES (m.order_id, m.order_total);
What would be the outcome of the above statement?
A. The ORDERS_MASTER table would contain the ORDER_IDs 1 and 2.
B. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 3.
C. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 4.
D. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2, 3 and 4.
Answer: C
244. View the Exhibit and examine the structure of the MARKS_DETAILS and MARKS
tables.Which is the best method to load data from the MARKS_DETAILS table
to the MARKS table?
A. Pivoting INSERT
B. Unconditional INSERT
C. Conditional ALL INSERT
D. Conditional FIRST INSERT
Answer: A
Pivoting INSERT 有行变列的功能
245. Evaluate the following SQL statement:
SELECT 2 col1,'y' col2 FROM dual
UNION
SELECT 1,'x' FROM dual
UNION
SELECT 3,NULL FROM dual
ORDER BY 2;
Which statement is true regarding the output of the SQL statement?
A. It would execute and the order of the values in the first column would
be 3, 2, 1.
B. It would execute and the order of the values in the first column would
be 1, 2, 3.
C. It would not execute because the column alias name has not been used in
the ORDER BY clause.
D. It would not execute because the number 2 in the ORDER BY clause would
conflict with the value 2 in
the first SELECT statement.
Answer: B
试验证明Order by 有优先级的,排前面的优先级最高, 第一列排序完成后再按第二列指定顺序排序, 而且默认
是升序.但是试验结果表明对于union这种形式组织起来的数据不完全是这样的,明确指出order by 的那列优先
级是最高的,而不是排前面的列优先级最高.
SQL> create table employees(first_name varchar(3),department_id varchar(3),salary varchar(3));
Sql>insert into employees values('1','1','1');
SQL> insert into employees values('1','2','3');
SQL> insert into employees values('1','3','2');
SQL> SELECT first_name, department_id, salary
FROM employees ORDER BY department_id, first_name, salary desc;
FIR DEP SAL (说明排前面的优先级高,这里没有顾及到第3列要求降序排列)
--- --- ---
1 1 1
1 2 3
1 3 2
SQL> update employees set department_id='1';
SQL> SELECT first_name, department_id, salary
2 FROM employees ORDER BY department_id, first_name, salary desc;
FIR DEP SAL
--- --- ---
1 1 3
1 1 2
1 1 1
SQL> update employees set first_name=salary;
SQL> SELECT first_name, department_id, salary
2 FROM employees ORDER BY department_id , first_name desc, salary;
FIR DEP SAL
--- --- ---
3 1 3
2 1 2
1 1 1
下面试验union聚集起来的数据order by情况
select 1,1,1
from dual
union
select 1,2,3
from dual
union
select 1,3,2
from dual
order by 3 desc;
(说明第3列要求降序排列优先级最高,而不是按排前面的列优先高来排序的,注意跟上面比较)
1 2 3
1 3 2
1 1 1
select 2,1,1
from dual
union
select 3,2,3
from dual
union
select 1,3,2
from dual
order by 2 desc,3 asc;
(说明第2列明确要求降序排列的优先级最高,而不是默认的第1列升序的优先级高)
1 3 2
3 2 3
2 1 1
select 2,1,1
from dual
union
select 3,2,3
from dual
union
select 1,3,2
from dual;
(在没有指明order by的前提下,这个时候按默认第一列升序排列,如果都相同,则按第2列升序)
1 3 2
2 1 1
3 2 3
SQL> SELECT 2 col1,'y' col2 FROM dual
2 UNION
3 SELECT 4,NULL FROM dual
4 union
5 SELECT 1,'x' FROM dual
6 UNION
7 SELECT 3,NULL FROM dual
8 ORDER BY 2;
---------- -
1 x
2 y
3
4
SQL> SELECT 2 col1,'y' col2 FROM dual
2 UNION
3 SELECT 4,NULL FROM dual
4 union
5 SELECT 1,'x' FROM dual
6 UNION
7 SELECT 3,NULL FROM dual
8 union
9 SELECT 5,NULL FROM dual
10 ORDER BY 2;
---------- -
1 x
2 y
3
4
5
247. User OE, the owner of the ORDERS table, issues the following command:
GRANT SELECT ,INSERT ON orders TO hr WITH GRANT OPTION;
The user HR issues the following command:
GRANT SELECT ON oe.orders TO scott;
Then, OE issues the following command:
REVOKE ALL ON orders FROM hr;
Which statement is correct?
A. The user SCOTT loses the privilege to select rows from OE.ORDERS.
B. The user SCOTT retains the privilege to select rows from OE.ORDERS.
C. The REVOKE statement generates an error because OE has to first revoke
the SELECT privilege from SCOTT.
D. The REVOKE statement generates an error because the ALL keyword cannot
be used for privileges that have been granted using WITH GRANT OPTION.
Answer: A
249. View the Exhibit and examine the data in the DEPARTMENTS tables.
Evaluate the following SQL statement:
SELECT department_id "DEPT_ID", department_name , 'b'
FROM departments WHERE department_id=90
UNION
SELECT department_id, department_name DEPT_NAME, 'a'
FROM departments WHERE department_id=10
Which two ORDER BY clauses can be used to sort the output of the above
statement? (Choose two.)
A. ORDER BY 3;
B. ORDER BY 'b';
C. ORDER BY DEPT_ID;
D. ORDER BY DEPT_NAME;
Answer: AC
Eg: 试验结果表明
1:如果””里面的内容全为大写,则order by时可以去掉””,否则必须加上
2:order by 别名的话只以第一个select时产生的名字有关
3:可以order by对应列所在数字
SQL> select emp_no "empno",ename ,'b' from emp
2 where emp_no=1
3 union
4 select emp_no,ename en_name,'a' from emp
5 where emp_no=3
6 order by "empno";
empno ENAME '
1 tt b
3 dd a
SQL> select emp_no empno,ename,'b' from emp
2 where emp_no=1
3 union
4 select emp_no,ename en_name,'a' from emp
5 where emp_no=3
6 order by empno;
EMPNO ENAME '
1 tt b
3 dd a
SQL> select emp_no "EMPNO",ename ,'b' from emp
2 where emp_no=1
3 union
4 select emp_no,ename en_name,'a' from emp
5 where emp_no=3
6 order by EMPNO;
EMPNO ENAME '
1 tt b
3 dd a
SQL> select emp_no "EMpNO",ename ,'b' from emp
2 where emp_no=1
3 union
4 select emp_no,ename en_name,'a' from emp
5 where emp_no=3
6 order by EMPNO;
第 6 行出现错误:
ORA-00904: "EMPNO": 标识符无效
250. A subquery is called a singlerow subquery when ____.
A. the inner query returns a single value to the main query
B. the inner query uses an aggregate function and returns one or more values
C. there is only one inner query in the main query and the inner query returns
one or more values
D. the inner query returns one or more values and the main query returns a
single value as output
Answer: A
single-row function指一行数据输入,返回一个值的函数。
如substr等。
而mutil-row function指多行数据输入,返回一个值的函数。
如sum、max等。
Eg: SQL> select a,a+b ,sum(b) from test group by a,a+b;
Ok
252. View the Exhibit and examine the structure of ORDER_ITEMS and ORDERS
tables.You need to remove from the ORDER_ITEMS table those rows that have
an order status of 0 or 1 in the ORDERS table.
Which DELETE statements are valid? (Choose all that apply.)
A. DELETE FROM order_items
WHERE order_id IN (SELECT order_id
FROM orders WHERE order_status in (0,1));
B. DELETE * FROM order_items
WHERE order_id IN (SELECT order_id
FROM orders WHERE order_status IN (0,1));
C. DELETE FROM order_items i
WHERE order_id = (SELECT order_id FROM orders o
WHERE i.order_id = o.order_id AND order_status IN (0,1));
D. DELETE FROM (SELECT * FROM order_items i,orders o
WHERE i.order_id = o.order_id AND order_status IN (0,1));
Answer: ACD
实验证明D是错误的
SQL> DELETE FROM (SELECT * FROM order_items i,orders o
WHERE i.order_id = o.order_id AND order_status IN (0,1));
WHERE i.order_id = o.order_id AND order_status IN (0,1))
ORA-00918: 未明确定义列
SQL> DELETE FROM (SELECT * FROM order_items i,orders o
WHERE i.order_id = o.order_id AND o.order_status IN (0,1));
DELETE FROM (SELECT * FROM order_items i,orders o
ORA-01752: 不能从没有一个键值保存表的视图中删除
253. View the Exhibit and examine the details of the EMPLOYEES table.
Evaluate the following SQL statement:
SELECT phone_number,
REGEXP_REPLACE(phone_number,'([[:digit:]]{3}).([[:digit:]]{3}).([[:dig
it:]]{4})', '(1) 2-3') "PHONE NUMBER" FROM employees;
The query was written to format the PHONE_NUMBER for the employees. Which
option would be the
correct format in the output?
A. xxxxxxxxxx
B. (xxx) xxxxxxx
C. (xxx) xxx-xxxx
D. xxx(xxx)xxxx
Answer: C
254. View the Exhibit and examine the structure of the CUSTOMERS table.
CUSTOMER_VU is a view based on CUSTOMERS_BR1 table which has the same
structure as CUSTOMERS table.
CUSTOMERS needs to be updated to reflect the latest information about the
customers.
What is the error in the following MERGE statement?
MERGE INTO customers c
USING customer_vu cv
ON (c.customer_id = cv.customer_id)
WHEN MATCHED THEN
UPDATE SET
c.customer_id = cv.customer_id,
c.cust_name = cv.cust_name,
c.cust_email = cv.cust_email,
c.income_level = cv.income_level
WHEN NOT MATCHED THEN
INSERT VALUES(cv.customer_id,cv.cust_name,cv.cust_email,cv,income_level)
WHERE cv.income_level >100000;
A. The CUSTOMER_ID column cannot be updated.
B. The INTO clause is misplaced in the command.
C. The WHERE clause cannot be used with INSERT.
D. CUSTOMER_VU cannot be used as a data source.
Answer: A
主键不能被更新
256. View the Exhibit and examine the structure of the PRODUCT_INFORMATION
table.Which two queries would work? (Choose two.)
A. SELECT product_name
FROM product_information WHERE list_price = (SELECT AVG(list_price)
FROM product_information);
B. SELECT product_status
FROM product_information GROUP BY product_status
WHERE list_price < (SELECT AVG(list_price) FROM product_information);
C. SELECT product_status
FROM product_information GROUP BY product_status
HAVING list_price > (SELECT AVG(list_price) FROM product_information);
D. SELECT product_name
FROM product_information WHERE list_price < ANY(SELECT AVG(list_price)
FROM product_information
GROUP BY product_status);
Answer: AD
Eg: SQL> select emp_no from emp
group by emp_no
where salary<(select avg(salary) from emp);
ORA-00933: SQL 命令未正确结束
group by 要放在语句的最后面
257. View the Exhibit and examine the structure of the EMP table.
You executed the following command to add a primary key to the EMP table:
ALTER TABLE emp ADD CONSTRAINT emp_id_pk PRIMARY KEY (emp_id)
USING INDEX emp_id_idx;
Which statement is true regarding the effect of the command?
A. The PRIMARY KEY is created along with a new index.
B. The PRIMARY KEY is created and it would use an existing unique index.
C. The PRIMARY KEY would be created in a disabled state because it is using
an existing index.
D. The statement produces an error because the USING clause is permitted only
in the CREATE TABLE command.
Answer: B
如果创建的主建上已有唯一索引,建主键时不会再另建索引,而可引用已存索引
259. Evaluate the following ALTER TABLE statement:
ALTER TABLE orders SET UNUSED order_date;
Which statement is true?
A. The DESCRIBE command would still display the ORDER_DATE column.
B. ROLLBACK can be used to get back the ORDER_DATE column in the ORDERS table.
C. The ORDER_DATE column should be empty for the ALTER TABLE command to
execute successfully.
D. After executing the ALTER TABLE command, you can add a new column called
ORDER_DATE to the ORDERS table.
Answer: D
260. View the Exhibit and examine the data in the PRODUCT_INFORMATION table.
There are some products listed in the PRODUCT_INFORMATION table that have
no value in the LIST_PRICE column. You issued the following SQL statement
to find out the PRODUCT_NAME for these products:
SELECT product_name, list_price
FROM product_information
WHERE list_price = NULL;
The query returns no rows. What changes would you make in the statement to
get the desired result?
A. Change the WHERE clause to WHERE list_price = 0
B. Change the WHERE clause to WHERE list_price = ' '.
C. Change the WHERE clause to WHERE list_price IS NULL.
D. In the WHERE clause, enclose NULL within single quotation marks.
E. In the WHERE clause, enclose NULL within double quotation marks.
Answer: C
261. View the Exhibit and examine the description of the EMPLOYEES table.
Evaluate the following SQL statement:
SELECT employee_id, last_name, job_id, manager_id, LEVEL
FROM employees START WITH employee_id = 101
CONNECT BY PRIOR employee_id=manager_id ;
Which two statements are true regarding the output of this command? (Choose
two.)
A. The output would be in top-down hierarchy starting with EMPLOYEE_ID having
value 101.
B. The output would be in bottom-up hierarchy starting with EMPLOYEE_ID
having value 101.
C. The LEVEL column displays the number of employees in the hierarchy under
the employee having the EMPLOYEE_ID 101.
D. The LEVEL column displays the level in the hierarchy at which the employee
is placed under the employee having the EMPLOYEE_ID 101.
Answer: AD
262. View the Exhibit and examine the description of the EMPLOYEES table.
You want to calculate the total remuneration for each employee. Total
remuneration is the sum of the annual salary and the percentage commission
earned for a year. Only a few employees earn commission.
Which SQL statement would you execute to get the desired output?
A. SELECT first_name, salary, salary*12+salary*commission_pct "Total"
FROM EMPLOYEES;
B. SELECT first_name, salary, salary*12+NVL((salary*commission_pct), 0)
"Total" FROM EMPLOYEES;
C. SELECT first_name, salary, salary*12 + NVL(salary, 0)*commission_pct
"Total" FROM EMPLOYEES;
D. SELECT first_name, salary, salary*12+(salary*NVL2(commission_pct,
salary,salary+commission_pct))"Total" FROM EMPLOYEES;
Answer: B
Remuneration:报酬 commission:委托 percentage:百分数
SQL> select 100+'' from dual;
如果加个空值返回也为空了
263. Which statement is true regarding external tables?
A. The default REJECT LIMIT for external tables is UNLIMITED.
B. The data and metadata for an external table are stored outside the
database.
C. ORACLE_LOADER and ORACLE_DATAPUMP have exactly the same functionality
when used with an external table.
D. The CREATE TABLE AS SELECT statement can be used to unload data into regular
table in the database from an external table.
Answer: D
265. View the Exhibit and examine the structure of the PRODUCT_INFORMATION
and INVENTORIES tables.You want to display the quantity on hand for all the
products available in the PRODUCT_INFORMATION table that have the
PRODUCT_STATUS as 'orderable'. QUANTITY_ON_HAND is a column in the
INVENTORIES table. The following SQL statement was written to accomplish the
task:
SELECT pi.product_id, pi.product_status, sum(i.quantity_on_hand)
FROM product_information pi LEFT OUTER JOIN inventories i
ON (pi.product_id = i.product_id)
WHERE (pi.product_status = 'orderable')
GROUP BY pi.product_id, pi.product_status;
Which statement is true regarding the execution of this SQL statement?
A. The statement would execute and produce the desired output.
B. The statement would not execute because the WHERE clause is used before
the GROUP BY clause.
C. The statement would not execute because prefixing table alias to column
names is not allowed with the
ON clause.
D. The statement would not execute because the WHERE clause is not allowed
with LEFT OUTER JOIN.
Answer: A
266. Evaluate the following SQL statement:
CREATE INDEX upper_name_idx ON product_information(UPPER(product_name));
Which query would use the UPPER_NAME_IDX index?
A. SELECT UPPER(product_name)
FROM product_information WHERE product_id = 2254;
B. SELECT UPPER(product_name) FROM product_information;
C. SELECT product_id FROM product_information
WHERE UPPER(product_name) IN ('LASERPRO', 'Cable');
D. SELECT product_id, UPPER(product_name)
FROM product_information
WHERE UPPER(product_name)='LASERPRO' OR list_price > 1000;
Answer: C
267. Given below is a list of datetime data types and examples of values stored
in them in a random order:
Datatype Example
1)INTERVAL YEAR TO MONTH a) '2003-04-15 8:00:00 -8:00'
2)TIMESTAMP WITH LOCAL TIME ZONE b) '+06 03:30:16.000000'
3)TIMESTAMP WITH TIME ZONE c) '17-JUN-03 12.00.00.000000 AM'
4)INTERVAL DAY TO SECOND d) '+02-00'
Identify the option that correctly matches the data types with the values.
A. 1d,2c,3a,4b
B. 1b,2a,3c,4d
C. 1b,2a,3d,4c
D. 1d,2c,3b,4a
Answer: A
268. View the Exhibit and examine the description of the ORDERS table.
The orders in the ORDERS table are placed through sales representatives only.
You are given the task to get the SALES_REP_ID from the ORDERS table of those
sales representatives who have successfully referred more than 10 customers.
Which statement would achieve this purpose?
A. SELECT sales_rep_id, COUNT(customer_id) "Total"
FROM orders HAVING COUNT(customer_id) > 10;
B. SELECT sales_rep_id, COUNT(customer_id) "Total"
FROM orders WHERE COUNT(customer_id) > 10
GROUP BY sales_rep_id;
C. SELECT sales_rep_id, COUNT(customer_id) "Total"
FROM orders GROUP BY sales_rep_id
HAVING total > 10;
D. SELECT sales_rep_id, COUNT(customer_id) "Total"
FROM orders GROUP BY sales_rep_id
HAVING COUNT(customer_id) > 10;
Answer: D
271. Which two statements are true regarding the types of table joins
available in Oracle Database 10g?(Choose two.)
A. You can use the JOIN clause to join only two tables.
B. You can explicitly provide the join condition with a NATURAL JOIN.
C. You can use the USING clause to join tables on more than one column.
D. You can use the ON clause to specify multiple conditions while joining
tables.
Answer: CD
Explicitly:明确 provide:规定
272. Which two statements are true regarding subqueries? (Choose two.)
A. The ORDER BY clause can be used in the subquery.
B. A subquery can be used in the FROM clause of a SELECT statement.
C. If the subquery returns NULL, the main query may still return result rows.
D. A subquery can be placed in a WHERE clause, GROUP BY clause, or a HAVING
clause.
E. Logical operators, such as AND, OR and NOT, cannot be used in the WHERE
clause of a subquery.
Answer: AB
274. Given below is a list of functions and their purpose in random order.
Function Purpose
1)NVL a) Used for evaluating NOT NULL and NULL values
2)NULLIF b) Used to return the first nonnull alues in a list of expressions
3)COALESCE c) Used to compare two expressions. If both are same, it returns
NULL;otherwise, it returns only the first expression.
4)NVL2 d) Used to convert NULL values to actual values
Identify the correct combination of functions and their usage.
A. 1a,2c,3b,4d
B. 1d,2c,3b,4a
C. 1b,2c,3d,4a
D. 1d,2b,3c,4a
Answer: B
1:Syntax: NULLIF(e1, e2)
Parameters: e1 and e2 are both expressions; required. Must be the same
datatype.If e1 and e2 are the same, NULLIF returns NULL. Otherwise, it returns
e1.
2: COALESCE(A,B,C,D)
返回参数表中第一个不为空的值(从左开始) A B C D 可以是字段,也可以是其他函
数的返回值或者表达式的结果值,如果所有的表达式都是空值
,最终将返回一个空值.使用COALESCE的秘密在于大部分包含空值的表达式最终将返
回空值(连接操作符"||"是一个值得注意的例外).
例如,空值加任何值都是空值,空值乘任何值也都是空值,依此类推.
3: NVL (expr1, expr2)->expr1 为NULL,返回expr2;不为NULL,返回expr1。注
意两者的类型要一致
NVL2 (expr1, expr2, expr3) ->expr1 不为NULL,返回expr2;为NULL,返回expr3。
expr2 和expr3 类型不同的话,expr3 会转换为expr2 的类型
NULLIF (expr1, expr2) ->相等返回NULL,不等返回expr1
COALESCE:接合
276. View the Exhibit and examine the description of the ORDERS table.
Which two WHERE clause conditions demonstrate the correct usage of conversion
functions? (Choosetwo.)
A. WHERE order_date > TO_DATE('JUL 10 2006','MON DD YYYY')
B. WHERE TO_CHAR(order_date,'MON DD YYYY') = 'JAN 20 2003'
C. WHERE order_date > TO_CHAR(ADD_MONTHS(SYSDATE,6),'MON DD YYYY')
D. WHERE order_date IN ( TO_DATE('Oct 21 2003','Mon DD YYYY'), TO_CHAR('NOV
21 2003','Mon DDYYYY') )
Answer: AB