_NAME NOT NULLVARCHAR2(30)
PROMO_CATEGORY NOT NULLVARCHAR2(30)
PROMO_COST NOT NULLNUMBER(10,2)
The management wants tosee a report of unique promotion costs in each promotion category.
Which query wouldachieve the required result
A. SELECT DISTINCTpromo_cost, promo_category FROM promotions;
B. SELECTpromo_category, DISTINCT promo_cost FROM promotions;
C. SELECT DISTINCTpromo_cost, DISTINCT promo_category FROM promotions;
D. SELECT DISTINCTpromo_category, promo_cost FROM promotions ORDER BY 1;
Answer: D
解析:distinct后的字段顺序不同,得到的结果顺序也不同,但是最终的内容都是一样的,所以A和D的差别主要是order by 1的区别,下面我们看看它的作用:
使用前:
scott@ORCL>selectdistinct job,sal from emp;
JOB SAL
--------- ----------
MANAGER 3324.24
SALESMAN 1600
SALESMAN 1250
CLERK 950
MANAGER 2450
ANALYST 3000
PRESIDENT 6300
ANALYST 1850
CLERK 1100
MANAGER 2975
SALESMAN 1500
CLERK 1430
已选择12行。
使用后:
scott@ORCL>selectdistinct job,sal from emp order by 1;
JOB SAL
--------- ----------
ANALYST 1850
ANALYST 3000
CLERK 950
CLERK 1100
CLERK 1430
MANAGER 2450
MANAGER 2975
MANAGER 3324.24
PRESIDENT 6300
SALESMAN 1250
SALESMAN 1500
SALESMAN 1600
已选择12行。
根据题意这里选择D选项更佳
19. eva luate thefollowing query:
SELECT INTERVAL '300'MONTH,
INTERVAL '54-2' YEAR TOMONTH,
INTERVAL'11:12:10.1234567' HOUR TO SECOND
FROM dual;
What is the correctoutput of the above query
A. +25-00 , +54-02, +0011:12:10.123457
B. +00-300, +54-02, +0011:12:10.123457
C. +25-00 , +00-650, +0011:12:10.123457
D. +00-300 , +00-650,+00 11:12:10.123457
Answer: A
解析:
scott@ORCL>SELECTINTERVAL '300' MONTH,
2 INTERVAL '54-2' YEAR TO MONTH,
3 INTERVAL '11:12:10.1234567' HOURTO SECOND
4 FROMdual;
INTERVAL'300'MONTH INTERVAL'54-2'YEARTOMONTH INTERVAL'11:12:10.1234567'HOURTOSECOND
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+25-00 +54-02 +00 11:12:10.123457
scott@ORCL>
官方文档:
INTERVAL YEAR TO MONTHData Type
INTERVAL YEAR TO MONTHstores a period of time using the YEAR and MONTH
datetime fields. Thisdata type is useful for representing the difference between two
datetime values whenonly the year and month values are significant.
Specify INTERVAL YEAR TOMONTH as follows:
INTERVAL YEAR[(year_precision)] TO MONTH
where year_precision isthe number of digits in the YEAR datetime field. The
default value ofyear_precision is 2.
引用网友:
由于MONTH 默认是2为有效位数,所以不能是300,就表示成YEAR TO MONTH 于是成了+25-00
第二个不够2位补0,第三个最后一位默认6位,收上来就是123457了
20. Which threestatements are true regarding the data types in Oracle Database 10g/11g (Choose
three.)
A. Only one LONG columncan be used per table.
B. A TIMESTAMP data typecolumn stores only time values with fractional seconds.
C. The BLOB data typecolumn is used to store binary data in an operating system file.
D. The minimum columnwidth that can be specified for a VARCHAR2 data type column is one.
E. The value for a CHARdata type column is blank-padded to the maximum defined column width.
Answer: ADE
解析:
引用oracle官方文档:
The use of LONG values is subject to these restrictions:
■ A table can contain only one LONG column.
■ You cannot create anobject type with a LONG attribute.
■ LONG columns cannotappear in WHERE clauses or in integrity constraints (except
that they can appear inNULL and NOT NULL constraints).
……….
T