1. 程式人生 > >oracle 0-5-1-中文註解

oracle 0-5-1-中文註解

如果你考證只背題庫,但是考完證保證你一個月之後忘光,如果你想弄點談資,看一遍《051考試指南》,然後背題庫。

如果你想靠這門技術吃飯或維繫生活,首先看一遍模擬題庫,閱讀051考試指南3遍以上,然後再做題;即使你能很快就能拿到證書,把書中的每個案例和題庫的各種情況模擬下,你會真正理解。推薦大家都看下daved部落格。

051中文

該文囊括了劉老師的註解和案例

本人粗略進行中文翻譯

1、

CREATE TABLE new_sales(prod_id, cust_id, order_dateDEFAULTSYSDATE)AS

SELECT prod_id, cust_id,

time_idFROM sales;

Which statement is true regarding the above command?上面命令哪個是正確的?

B. The NEW_SALES table wouldget created and all the NOT NULL constraints defined on the specified columnswould be passed to the new table.

隱式宣告的NOT NULL約束(例如主鍵的NOT NULL約束)不會繼承。

2、

Which views can have all DML operations performed on it?(Choose all that apply.)

--A.   

CREATE VIEW v3 AS SELECT * FROM SALESWHERE cust_id=2034WITHCHECKOPTION;

--B.   

CREATE VIEW v1 AS SELECT * FROM SALESWHERE time_id<=SYSDATE-2*365WITHCHECKOPTION;

解釋:插入檢視中沒有記錄是可以的。

C,D因為指定了具體的列,而且D中指定了分組函式。

3、

Youneed to extract details of those products in the SALES table where the PROD_IDcolumn contains the string '_D123'.

Which WHERE clausecould be used in the SELECT statement to get the required output? (B)

B.WHEREprod_idLIKE'%\_D123%' ESCAPE'\'

4、

Whichtwo statements are true regarding single row functions? (Choose two.) (DE)

D. They always return asingle result row for every row of a queried table.他們總是返回單個結果行(為一個查詢表的每行)

E. They can return adata type value different from the one that is referenced.他們返回一個數據型別值區別於引用的的那個

單行函式可以巢狀任意層,而分組函式最多可以巢狀2層。

C,也可以是函式的返回值。

5、

Which SQL statementswould display the value 1890.55 as $1,890.55? (Choose three)

A. SELECTTO_CHAR(1890.55,'$0G000D00')FROM DUAL;

D. SELECTTO_CHAR(1890.55,'$99G999D00')FROM DUAL;

E. SELECTTO_CHAR(1890.55,'$99G999D99')FROM DUAL;

不允許混合合適符號和字母指定格式

6、

Examine the structure of the SHIPMENTS table:

name            Null       Type

PO_ID           NOT NULL    NUMBER(3)

PO_DATE         NOT NULL    DATE

SHIPMENT_DATE  NOT NULL    DATE

SHIPMENT_MODE               VARCHAR2(30)

SHIPMENT_COST               NUMBER(8,2)

你想產生一個報告顯示PO_ID,如果shipment_date比PO_DATE時間晚1個月,將罰款;每天罰款20美元;執行以下查詢::

SELECT po_id,

CASE WHEN MONTHS_BETWEEN (shipment_date,po_date)>1 THEN TO_CHAR((shipment_date- po_date)*20)ELSE'No Penalty'END PENALTY

FROM shipments;

SELECT po_id,DECODE(MONTHS_BETWEEN(po_date,shipment_date)>1,TO_CHAR((shipment_date- po_date)*20),'No Penalty') PENALTY

FROM shipments;

Which statement is true regarding the above commands?

C. Only the first queryexecutes successfully and gives the correct result.

DECODE函式在此不適用。

7、

Which two statements are true regarding the USING and ONclauses in table joins? (Choose two.)哪兩個語句是正確的,關於usingon條件(在表連線中)

A. Both USING and ON clauses can beused for equijoins and nonequijoins.

B. A maximum of one pair of columns can be joinedbetween two tables using the ON clause.

C. The ON clause can beused to join tables on columns that have different names but compatible datatypes.On條件可以用join表的列,有不同名字,但相容資料型別)

D. The WHERE clause can be used to apply additionalconditions in SELECT statements containing the ON or the USING clause.Where條件可以被用於去應用slect語句中的額外條件(包含onusing條件)

A. USING只能用於等值連線。

B. 使用ON子句進行連線時,可以指定多個列對。

C.ON條件可以用於連線表(列有不同的名字,但相容資料型別)

D.WHERE條件可以用於應用額外的條件(在select語句中包含on或using條件之外)

8、

View the Exhibit and examine the structureof the CUSTOMERS table.

Which twotasks would requiresubqueriesorjoins to be executed in a singlestatement? (Choose two.)在單個語句中需要執行子查詢或連線才能實現的任務?

A. listing of customers who do not have acredit limit and were born before 1980列出沒有credit限制且出生在1980年前的客戶

B. finding the number of customers, in eachcity, whose marital status is 'married'找出每個城市中已婚客戶的數量

C. finding the average credit limit of malecustomers residing in 'Tokyo' or 'Sydney'找出位於tokyo或sydney中male客戶的credit限制的平均值

D. listing of thosecustomers whose credit limit is the same as the credit limit of customersresiding in the city 'Tokyo'列舉這些customerscredit limit與相同的(位於tokyo城市的customers相同))

E. finding the number of customers, in each city, whose creditlimit is more than the average credit limit of all the customers發現每城市中客戶的數量,哪些客戶限制大於所有客戶的平均限制。)

A SELECT*FROM customersWHERE cust_credit_limitIS NULL AND cust_year_of_birth<1980;

B SELECT cust_city,COUNT(maritial_status)WHERE maritial_status ='married'GROUPBY cust_city;

C SELECTAVG(cust_credit_limit)FROM customers WHERE cityIN('Tokyo','Sydney')AND gender ='M'

9

Which statement is true regarding the INTERSECT operator?關於交叉intersect操作符正確的是

A. It ignores NULL values.

B. Reversing the order of the intersectedtables alters the result.交叉表倒序改變結果X

C. The names of columns in all SELECTstatements must be identical.

D. The number of columns and data types must be identical forall SELECT statements in the query.在查詢中所有的select語句的列數量和資料型別必須是完全相同的。

Intersect操作不忽略空值。它會比較null,此時可以認為null =null

10、

View the Exhibit; examine the structure ofthe PROMOTIONS 提升推廣table.

Each promotion has a duration of at leastseven days .每一次推廣至少有7天的期限

Your manager has asked you to generate areport, which provides the weekly cost for each promotion done to l date.你管理者讓你生成一個報告,按照周成本

Which query would achieve the required result? 哪個查詢可完成你要求的結果

A. SELECT promo_name, promo_cost/promo_end_date-promo_begin_date/7FROM promotions;

B. SELECT promo_name,(promo_cost/promo_end_date-promo_begin_date)/7FROM promotions;

C. SELECT promo_name, promo_cost/(promo_end_date-promo_begin_date/7)FROM promotions;

D. SELECT promo_name, promo_cost/((promo_end_date-promo_begin_date)/7)FROM promotions;

11、

View the Exhibit and examine the structureof the PRODUCTS table. Allproducts have a list price. 所有產品有一個公開列價You issuethe following command to display the total price of each product after adiscount of 25% and a tax of 15% are applied on it. Freight charges of $100have to be applied to all the products.你發起下列命令去顯示每一個產品的總價(折扣25%,稅金提升15%之後);貨運費100美元已經應用到所有的產品中。

SELECT prod_name, prod_list_price-(prod_list_price*(25/100)) +(prod_list_price -(prod_list_price*(25/100))*(15/100))+100

AS "TOTAL PRICE"

FROM products;

What would be the outcome if all the parentheses(括號) areremoved from the above statement?如果所有的括號從上面的語句中刪除,會有什麼的結果?

A. It produces a syntax error.

B. The result remains unchanged.

C. The total price value would be lowerthan the correct value.

D. The total price value would be higherthan the correct value.

12、

You need to produce a report where eachcustomer's credit limit has been incremented by $1000. In the output, thecustomer's last name should have the heading Name and the incremented credit limitshould be labeled New Credit Limit. The column headings should have only thefirst letter of each word in uppercase .你需要生成一個報告(每個客戶的creditlimit增加1000美元),在最後輸出時,客戶的last name有heading Name, New Credit Limit.

Which statement would accomplish this requirement?

A. SELECT cust_last_name Name,cust_credit_limit+1000 "New Credit Limit" FROM customers;

B. SELECT cust_last_name AS Name, cust_credit_limit+1000ASNew CreditLimit FROM customers;

C. SELECT cust_last_nameAS"Name", cust_credit_limit+1000 AS"New Credit Limit"FROM customers;

D.SELECTINITCAP(cust_last_name)"Name", cust_credit_limit+1000 INITCAP("NEW CREDIT LIMIT")FROM customers;headings

A也正確

13、

View the Exhibit and examine the structureof the PRODUCTS table. You need to generate a report in the following format:

CATEGORIES

5MP Digital PhotoCamera's category is Photo Y Box's category is Electronics

Envoy Ambassador'scategory is Hardware

Which two queries would give the requiredoutput? (Choose two.)

A.SELECT prod_name|| q'''scategory is ' || prod_category CATEGORIESFROM products;

B. SELECT prod_name || q'['s ]'category is ' || prod_category CATEGORIESFROM products;

C. SELECT prod_name || q'\'s\'    ' ||categoryis ' || prod_category CATEGORIES FROM products;

D. SELECT prod_name || q'<'s >' ||'category is ' || prod_category CATEGORIESFROM products;

注意:從Oralce 10g開始,可以使用q’<>/[]/{}’,引號中用特殊字元括起來即可。

14

Usingthe CUSTOMERS table, you need to generate a report that shows 50% of eachcredit amount in each income level. The report shouldNOTshow anyrepeatedcredit amounts ineachincome level. 使用customers表,你需要產生一個報告來顯示在每一個收入級別中的每個賒賬金額的50% 報告不應該顯示每一個收入級別的重複的信貸額。Which query would give the required result?

A.SELECT cust_income_level,DISTINCT cust_credit_limit*0.50AS"50% Credit Limit"FROM customers;

B. SELECT DISTINCT cust_income_level,DISTINCT cust_credit_limit*0.50AS"50% Credit Limit"FROM customers;

C.SELECTDISTINCT cust_income_level|| cust_credit_limit* 0.50 AS "50% Credit Limit"FROM customers;

D. SELECT cust_income_level || cust_credit_limit*0.50AS"50% Credit Limit"FROM customers;

解釋:

A. DISTINCT關鍵字只能出現在第一列之前。

B. 一個SELECT語句上只能出現一個DISTINCT關鍵字

15

View theExhibit and examine the data in the CUSTOMERS table.

Evaluatethe following query:評價下列查詢

SELECT cust_nameAS"NAME",

       cust_credit_limit/2AS MIDPOINT,

       MIDPOINT +100AS"MAX LOWER LIMIT"

FROM customers;

Theabove query produces an error on execution. What is the reason for the error?

A. An alias cannot be used inan expression.別名不能用在表示式中

B. Thealias NAME should not be enclosed with in double quotation marks .

C. TheMIDPOINT+100 expression gives an error because CUST_CREDIT_LIMIT contains NULLvalues.

D. The aliasMIDPOINT should be enclosed within double quotation marks for theCUST_CREDIT_LIMIT/2 expression .

16

Evaluatethe following query:

SELECT promo_name || q'{'sstartdate was}' || promo_begin_date

AS "Promotion Launches"

FROM promotions;

What would be theoutcome of the above query?

A. Itproduces an error because flower braces have been used.

B. Itproduces an error because the data types are not matching.

C. It executes successfully and introduces an 's at the end of eachpromo_name in the output.執行成功7369's start date was SMITH

D. Itexecutes successfully and displays the literal " {'s start date was }" for each row in the output.

17

View theExhibit and examine the data in the EMPLOYEES table.

You wantto generate a report showing the total compensation paid to each employee to date.You issue the following query:你想生成一個報告顯示總和的賠償支付給每個員工的日期。

SELECT ename || ' joined on '|| hiredate||

       ', the total compensation paid is '||

       TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365)* sal + comm)

       "COMPENSATION UNTIL DATE"

FROM employees;

What is the outcome?

A. Itgenerates an error because the alias is not valid.

B. Itexecutes successfully and gives the correct output.

C. It executes successfullybut does not give the correct output.

D. Itgenerates an error because the usage of the       ROUND function in the expression is not valid.

E. It generates an error because theconcatenation operator can be used to combine only two items.

解釋:有些記錄的comm為空。

18

Examinethe structure of the PROMOTIONS table:

name             Null       Type

PROMO_ID        NOT NULL    NUMBER(6)

PROMO_NAME      NOT NULL    VARCHAR2(30)

PROMO_CATEGORY NOT NULL    VARCHAR2(30)

PROMO_COST      NOT NULL    NUMBER(10,2)

Themanagement wants to see a report of unique promotion costs in each promotioncategory. 管理者想看一個報告(每一個推廣類別的推廣費用唯一的)Which querywould achieve the required result?

A.

SELECT DISTINCT promo_cost, promo_categoryFROM promotions;

B. 

SELECT promo_category,DISTINCT promo_costFROM promotions;

C. 

SELECT DISTINCT promo_cost, DISTINCT promo_category FROM promotions;

D. 

SELECTDISTINCT promo_category, promo_costFROM promotionsORDER BY 1;

19重點查詢資料

Evaluatethe following query:

SELECT INTERVAL '300' MONTH,INTERVAL'54-2'YEARTO MONTH,

INTERVAL '11:12:10.1234567' HOUR TO SECOND

FROM dual;

What is the correctoutput 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

SQL Language Reference->Literal

20

Whichthree statements are true regarding the data types in Oracle Database 10g/11g?(Choose three.)

A. Only one LONG column canbe used per table.每表中只有一個long列可用

B. ATIMESTAMP data type column stores only time values with fractional seconds.

C. TheBLOB data type column is used to store binary data in an operating system file.

D. The minimum column widththat can be specified for a VARCHAR2 data type column is one.  varchar2資料型別列可以指定最小的列寬度為1

E. The value for a CHAR datatype column is blank-padded to the maximum defined column width. Char資料型別列的值可以通過填充空格來設定列寬度

21

Examinethe description of the EMP_DETAILS table given below:

name        NULL        TYPE

EMP_ID      NOT NULL    NUMBER

EMP_NAME    NOT NULL    VARCHAR2 (40)

EMP_IMAGE               LONG

Which two statements are true regarding SQLstatements that can be executed on the EMP_DETAIL table? (Choose two.)

A. AnEMP_IMAGE column can be included in the GROUP BY clause.

B. An EMP_IMAGE column cannot be included in the ORDER BY clause.

C. You cannot add a new column to the table with LONG as the datatype.

D. Youcan alter the table to include the NOT NULL constraint on the EMP_IMAGE column.

Long列不能groupby,order by;每表只有一long列;不能設定為not null;

22

You needto create a table for a banking application. One of the columns in the tablehas the following requirements:你需要建立一個表給銀行應用。表中某列有以下要求:

1) Youwant a column in the table to store the duration of the credit period.你想一列儲存貸款期限的時間

2) Thedata in the column should be stored in a format such that it can be easilyadded and subtracted with DATE data type without using conversion functions.列的資料應該儲存在這樣的格式(容易新增和扣除date資料型別;沒有使用轉換函式)

3) Themaximum period of the credit provision in the application is 30 days.(信用貸款條款最大事件為30天)

4) Theinterest has to be calculated for the number of days an individual has taken acredit for.(利息不得不按照天獨立來計算)

Whichdata type would you use for such a column in the table?表中該列資料型別:

A. DATE

B. NUMBER

C. TIMESTAMP

D. INTERVAL DAY TO SECONDinterval day to second

E. INTERVALYEAR TO MONTH

23

Examinethe structure proposed推薦的 for theTRANSACTIONS table:

name         Null      Type

TRANS_ID    NOT NULL  NUMBER(6)

CUST_NAME   NOT NULL  VARCHAR2(20)

CUST_STATUS NOT NULL  CHAR

TRANS_DATE  NOT NULL  DATE

TRANS_VALIDITY        VARCHAR2

CUST_CREDIT_LIMIT     NUMBER

Whichstatements are trueregarding the creation and storage of data in the above table structure?(Choose all that apply.)哪個語句是正確的,關於上述表結構的資料建立和儲存方面:

A. The CUST_STATUS column would give anerror.

B. The TRANS_VALIDITY column would give an error.

C. The CUST_STATUS column would store exactly one character.

D. TheCUST_CREDIT_LIMIT column would not be able to store decimal values.()

E. TheTRANS_VALIDITY column would have a maximum size of one character.

F. TheTRANS_DATE column would be able to store day, month, century, year, hour,minutes, seconds, andfractionsof seconds.X

解釋:

B,VARCHAR2型別必須指定最大長度

F,DATE型別,沒有fractions of seconds.

Number型別可以儲存小數值

24

Examinethe structure proposed for the TRANSACTIONS table:

name         Null       Type

TRANS_ID    NOT NULL   NUMBER(6)

CUST_NAME   NOT NULL   VARCHAR2(20)

CUST_STATUS NOT NULL   VARCHAR2

TRANS_DATE  NOT NULL   DATE

TRANS_VALIDITY         INTERVALDAYTO SECOND

CUST_CREDIT_VALUE      NUMBER(10)

Which two statements are true regarding thestorage of data in the above table structure? (Choose two.)

A. TheTRANS_DATE column would allow storage of dates only in the dd-mon-yyyy format.

B. The CUST_CREDIT_VALUE column would allow storage of positive andnegative integers.該列允許儲存正和負數

C. The TRANS_VALIDITY column would allow storage of a time intervalin days, hours, minutes, and seconds.基於時間間隔天,小時,分鐘,秒

D. TheCUST_STATUS column would allow storage of data up to the maximum VARCHAR2 sizeof 4,000 characters.

25

You needto create a table with the following column specifications:你需要下面的列要求建立表:

1. EmployeeID (numeric data type) for each employee

2. EmployeeName (character data type) that stores the employee name

3. Hiredate, which stores the date of joining the organization for each employee

4. Status(character data type), that contains the value 'ACTIVE' if no data is entered

5. Resume(character large object [CLOB] data type), which contains the resume submittedby the employee

Which isthe correct syntax to create this table?建立這個表的正確的語法

A. 

CREATE TABLE EMP_1

(

  emp_id     NUMBER(4),

  emp_name   VARCHAR2(25),

  start_date DATE,

  e_status   VARCHAR2(10)DEFAULT'ACTIVE',

  resume     CLOB(200)

);

B. 

CREATE TABLE 1_EMP

(

  emp_id     NUMBER(4),

  emp_name   VARCHAR2(25),

  start_date DATE,

  emp_status VARCHAR2(10)DEFAULT'ACTIVE',

  resume     CLOB

);

C. 

CREATE TABLE EMP_1

(

  emp_id     NUMBER(4),

  emp_name   VARCHAR2(25),

  start_date DATE,

  emp_status VARCHAR2(10)DEFAULT"ACTIVE",

  resume     CLOB

);

D. 

CREATETABLE EMP_1

(

  emp_id      NUMBER,

  emp_name    VARCHAR2(25),

  start_date  DATE,

  emp_status  VARCHAR2(10) DEFAULT 'ACTIVE',

  resume      CLOB

);

解釋:

ACLOB不能指定精度

B,表名得以字母開頭

Cemp_status列預設值應該為’ACTIVE’,不應該用雙引號

26

Which isthe valid CREATE TABLE statement?哪個是正確建立表的語句

A. 

CREATETABLE emp9$#(emp_noNUMBER (4));表名9$#是正確的

B. 

CREATE TABLE 9emp$#(emp_noNUMBER(4));表名數字開頭

C. 

CREATE TABLE emp*123(emp_noNUMBER(4));表名帶*

D. 

CREATE TABLE emp9$#(emp_noNUMBER(4),dateDATE);列名date

解釋:

B,表名不允許以數字開頭

C,表名中不允許出現特殊符號*

D,date為保留字,不能作為列名。

27

Whichtwo statements are true regarding tables? (Choose two.)關於表哪兩個是正確的

A. Atable name can be of any length.表名長度30

B. Atable can have any number of columns.表列數

C. Acolumn that has a DEFAULT value cannot store null values.列有預設值不能儲存空值,有問題,可以儲存空值

D. Atable and a view can have the same name in the same schema.同架構下表和檢視有相同的名字錯誤

E. A table and a synonym can have the same name in the same schema.相同架構下表名和同義詞相同名

F. The same table name can be used indifferent schemas in the same database.同一庫下不同架構下可以有相同表名

解釋:

E,有問題(luise)

28

Whichtwo statements are true regarding constraints? (Choose two.)關於約束的兩個正確的語句

A. Aforeign key cannot contain NULL values.糾正:外來鍵可以包含NULL值

B. A column with the UNIQUE constraint can contain NULL values.unique約束列可以包含NULL

C. Aconstraint is enforced only for the INSERT operation on a table.約束只有在insert操作時被強制

D. A constraint can be disabled even if the constraint columncontains data.即使列包含資料約束也可以被禁用

E. Allconstraints can be defined at the column level as well as the table level.所有的約束可以定義在列級也可以定義在表級

問題理解:哪些約束可以定義在列級,哪些可以定義在表級;

29

Whichtwo statements are true regarding constraints? (Choose two.)關於約束正確的兩個語句

A. Aforeign key cannot contain NULL values.

B. The column with a UNIQUE constraintcan store NULLS .

C. Aconstraint is enforced only for an INSERT operation on a table.

D. You can have more than one column in a table as part of a primarykey.一個表的多個列可以被看作一個pk

30

Evaluatethe following CREATE TABLE commands:評估一下建立table的命令

CREATE TABLE orders

(

  ord_no NUMBER(2