1Z0-051 Premium Bundle

1Z0-051 Premium Bundle

Oracle Database: SQL Fundamentals I Certification Exam

4.5 
(600 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
May 20, 2024Last update

Oracle 1Z0-051 Free Practice Questions

Q1. - (Topic 2) 

View the Exhibit and examine the data in the PROMOTIONS table. 

PROMO_BEGIN_DATE is stored in the default date format, dd-mon-rr. 

You need to produce a report that provides the name, cost, and start date of all promos in the POST category that were launched before January 1, 2000. 

Which SQL statement would you use? 

A. SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category = 'post' AND promo_begin_date < '01-01-00' 

B. SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_cost LIKE 'post%' AND promo_begin_date < '01-01-2000' 

C. SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category LIKE 'P%' AND promo_begin_date < '1-JANUARY-00' 

D. SELECT promo_name, promo_cost, promo_begin_date FROM promotions WHERE promo_category LIKE '%post%' AND promo_begin_date < '1-JAN-00' 

Answer:

Q2. - (Topic 1) 

See the Exhibit and examine the structure of the CUSTOMERS table: 

Using the CUSTOMERS table, you need to generate a report that shown the average credit limit for customers in WASHINGTON and NEW YORK. 

Which SQL statement would produce the required result? 

A. 

SELECT cust_city, AVG(cust_credit_limit) 

FROM customers 

WHERE cust_city IN ('WASHINGTON','NEW YORK') 

GROUP BY cust_credit_limit, cust_city; 

B. 

SELECT cust_city, AVG(cust_credit_limit) 

FROM customers 

WHERE cust_city IN ('WASHINGTON','NEW YORK') 

GROUP BY cust_city,cust_credit_limit; 

C. 

SELECT cust_city, AVG(cust_credit_limit) 

FROM customers 

WHERE cust_city IN ('WASHINGTON','NEW YORK') 

GROUP BY cust_city; 

D. 

SELECT cust_city, AVG(NVL(cust_credit_limit,0)) 

FROM customers 

WHERE cust_city IN ('WASHINGTON','NEW YORK'); 

Answer:

Explanation: 

Creating Groups of Data: GROUP BY Clause Syntax You can use the GROUP BY clause to divide the rows in a table into groups. You can then use the group functions to return summary information for each group. In the syntax: group_by_expression Specifies the columns whose values determine the basis for grouping rows Guidelines 

If you include a group function in a SELECT clause, you cannot select individual results as well, unless the individual column appears in the GROUP BY clause. You receive an error message if you fail to include the column list in the GROUP BY clause. 

Using a WHERE clause, you can exclude rows before dividing them into groups. 

You must include the columns in the GROUP BY clause. 

You cannot use a column alias in the GROUP BY clause. 

Q3. - (Topic 1) 

Which object privileges can be granted on a view? 

A. none 

B. DELETE, INSERT,SELECT 

C. ALTER, DELETE, INSERT, SELECT 

D. DELETE, INSERT, SELECT, UPDATE 

Answer:

Explanation: Object privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE. 

Incorrect Answer: AObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE BObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE CObject privilege on VIEW is DELETE, INSERT, REFERENCES, SELECT and UPDATE 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 13-12 

Q4. - (Topic 1) 

Which statement is true regarding the default behavior of the ORDER BY clause? 

A. In a character sort, the values are case-sensitive 

B. NULL values are not considered at all by the sort operation 

C. Only those columns that are specified in the SELECT list can be used in the ORDER BY clause 

D. Numeric values are displayed from the maximum to the minimum value if they have decimal positions 

Answer:

Explanation: 

Character Strings and Dates 

Character strings and date values are enclosed with single quotation marks. 

Character values are case-sensitive and date values are format-sensitive. 

The default date display format is DD-MON-RR. 

Q5. - (Topic 1) 

See the Exhibit and examine the structure of the PROMOTIONS table: Exhibit:

 

Using the PROMOTIONS table, you need to find out the average cost for all promos in the 

range $0-2000 and $2000-5000 in category A. 

You issue the following SQL statements: 

Exhibit: 

What would be the outcome? 

A. It generates an error because multiple conditions cannot be specified for the WHEN clause 

B. It executes successfully and gives the required result 

C. It generates an error because CASE cannot be used with group functions 

D. It generates an error because NULL cannot be specified as a return value 

Answer:

Explanation: 

CASE Expression Facilitates conditional inquiries by doing the work of an IF-THEN-ELSE statement: CASE expr WHEN comparison_expr1 THEN return_expr1 [WHEN comparison_expr2 THEN return_expr2 WHEN comparison_exprn THEN return_exprn ELSE else_expr] END 

Q6. - (Topic 1) 

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

A. They can be nested only to two levels 

B. They always return a single result row for every row of a queried table 

C. Arguments can only be column values or constant 

D. They can return a data type value different from the one that is referenced 

E. They accept only a single argument 

Answer: B,D 

Explanation: 

A function is a program written to optionally accept input parameters, perform an operation, or return a single value. A function returns only one value per execution. Three important components form the basis of defining a function. The first is the input parameter list. It specifies zero or more arguments that may be passed to a function as input for processing. These arguments or parameters may be of differing data types, and some are mandatory while others may be optional. The second component is the data type of its resultant value. Upon execution, only one value is returned by the function. The third encapsulates the details of the processing performed by the function and contains the program code that optionally manipulates the input parameters, performs calculations and operations, and generates a return value. 

Q7. - (Topic 1) 

Evaluate the SQL statement: 

TRUNCATE TABLE DEPT; 

Which three are true about the SQL statement? (Choose three.) 

A. It releases the storage space used by the table. 

B. It does not release the storage space used by the table. 

C. You can roll back the deletion of rows after the statement executes. 

D. You can NOT roll back the deletion of rows after the statement executes. 

E. An attempt to use DESCRIBE on the DEPT table after the TRUNCATE statement executes will display an error. 

F. You must be the owner of the table or have DELETE ANY TABLE system privileges to truncate the DEPT table 

Answer: A,D,F 

Explanation: 

A: The TRUNCATE TABLE Statement releases storage space used by the table, 

D: Can not rollback the deletion of rows after the statement executes, 

F: You must be the owner of the table or have DELETE ANY TABLE system privilege to truncate the DEPT table. 

Incorrect Answer: Cis not true Dis not true Eis not true 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 8-18 

Q8. - (Topic 2) 

Examine the data in the LIST_PRICE and MIN_PRICE columns of the PRODUCTS table: 

Which two expressions give the same output? (Choose two.) 

A. NVL(NULLIF(list_price, min_price), 0) 

B. NVL(COALESCE(list_price, min_price), 0) 

C. NVL2(COALESCE(list_price, min_price), min_price, 0) 

D. COALESCE(NVL2(list_price, list_price, min_price), 0) 

Answer: B,D 

Explanation: 

Using the COALESCE Function 

The advantage of the COALESCE function over the NVL function is that the COALESCE 

function can take multiple alternate values. 

If the first expression is not null, the COALESCE function returns that expression; 

otherwise, it does a COALESCE of the remaining expressions. 

Using the COALESCE Function 

The COALESCE function returns the first non-null expression in the list. 

Syntax 

COALESCE (expr1, expr2, ... exprn) In the syntax: 

expr1 returns this expression if it is not null 

expr2 returns this expression if the first expression is null and this expression is not null 

exprn returns this expression if the preceding expressions are null Note that all expressions must be of the same data type. 

Q9. - (Topic 1) 

See the Exhibit and Examine the structure of the CUSTOMERS table: 

Using the CUSTOMERS table, you need to generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose credit limit has not been entered should have the message "Not Available" displayed. 

Which SQL statement would produce the required result? 

A. SELECT NVL(cust_credit_limit,'Not Available')*.15 "NEW CREDIT" FROM customers; 

B. SELECT NVL(cust_credit_limit*.15,'Not Available') "NEW CREDIT" FROM customers; 

C. SELECT TO_CHAR(NVL(cust_credit_limit*.15,'Not Available')) "NEW CREDIT" FROM customers; 

D. SELECT NVL(TO_CHAR(cust_credit_limit*.15),'Not Available') "NEW CREDIT" FROM customers; 

Answer:

Explanation: 

NVL Function 

Converts a null value to an actual value: 

Data types that can be used are date, character, and number. 

Data types must match: 

– 

NVL(commission_pct,0) 

– 

NVL(hire_date,'01-JAN-97') 

– 

NVL(job_id,'No Job Yet') 

Q10. - (Topic 2) 

Examine the structure of the PRODUCTS table: 

You want to display the names of the products that have the highest total value for UNIT_PRICE *QTY_IN_HAND. 

Which SQL statement gives the required output? 

A. 

SELECT prod_name FROM products WHERE (unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) FROM products); 

B. 

SELECT prod_name FROM products WHERE (unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) FROM products GROUP BY prod_name); 

C. 

SELECT prod_name FROM products GROUP BY prod_name HAVING MAX(unit_price * qty_in_hand) = (SELECT MAX(unit_price * qty_in_hand) FROM products GROUP BY prod_name); 

D. 

SELECT prod_name 

FROM products 

WHERE (unit_price * qty_in_hand) = (SELECT MAX(SUM(unit_price * qty_in_hand)) 

FROM products) 

GROUP BY prod_name; 

Answer:

Q11. - (Topic 1) 

See the Exhibit and examine the structure and data in the INVOICE table: Exhibit: 

Which two SQL statements would execute successfully? (Choose two.) 

A. SELECT MAX(inv_date),MIN(cust_id) FROM invoice; 

B. SELECT AVG(inv_date-SYSDATE),AVG(inv_amt) FROM invoice; 

C. SELECT MAX(AVG(SYSDATE-inv_date)) FROM invoice; 

D. SELECT AVG(inv_date) FROM invoice; 

Answer: A,B 

Q12. - (Topic 2) 

The CUSTOMERS table has these columns: CUSTOMER_ID NUMBER(4) NOT NULL 

CUSTOMER_NAME VARCHAR2(100) NOT NULL 

CUSTOMER_ADDRESS VARCHAR2(150) 

CUSTOMER_PHONE VARCHAR2(20) 

You need to produce output that states "Dear Customer customer_name, ". 

The customer_name data values come from the CUSTOMER_NAME column in the CUSTOMERS table. 

Which statement produces this output? 

A. SELECT dear customer, customer_name, FROM customers; 

B. SELECT "Dear Customer", customer_name || ',' FROM customers; 

C. SELECT 'Dear Customer ' || customer_name ',' FROM customers; 

D. SELECT 'Dear Customer ' || customer_name || ',' FROM customers; 

E. SELECT "Dear Customer " || customer_name || "," FROM customers; 

F. SELECT 'Dear Customer ' || customer_name || ',' || FROM customers; 

Answer:

Explanation: Concatenation operator to create a resultant column that is a character expression. 

Incorrect Answer: Ano such dear customer column Binvalid syntax Cinvalid syntax Einvalid syntax Finvalid syntax 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 1-18 

Q13. - (Topic 1) 

View the Exhibit and examine the structure of the PROMOTIONS table. 

You have to generate a report that displays the promo name and start date for all promos that started after the last promo in the 'INTERNET' category. 

Which query would give you the required output? 

A. 

SELECT promo_name, promo_begin_date FROM promotions WHERE promo_begin_date > ALL (SELECT MAX(promo_begin_date) FROM promotions )AND promo_category = 'INTERNET' 

B. 

SELECT promo_name, promo_begin_date FROM promotions WHERE promo_begin_date IN (SELECT promo_begin_date FROM promotions WHERE promo_category='INTERNET'); 

C. 

SELECT promo_name, promo_begin_date FROM promotions WHERE promo_begin_date > ALL (SELECT promo_begin_date FROM promotions WHERE promo_category = 'INTERNET'); 

D. 

SELECT promo_name, promo_begin_date FROM promotions WHERE promo_begin_date > ANY (SELECT promo_begin_date FROM promotions WHERE promo_category = 'INTERNET'); 

Answer:

Q14. - (Topic 2) 

Which two statements complete a transaction? (Choose two) 

A. DELETE employees; 

B. DESCRIBE employees; 

C. ROLLBACK TO SAVEPOINT C; 

D. GRANT SELECT ON employees TO SCOTT; 

E. ALTER TABLE employeesSET UNUSED COLUMN sal; 

F. Select MAX(sal)FROM employeesWHERE department_id = 20; 

Answer: D,E 

Explanation: 

D: GRANT is a DML operation which will cause an implicit commit 

E: It is important to understand that an implicit COMMIT occurs on the database when a user exits SQL*Plus or issues a data-definition language (DDL) command such as a CREATE TABLE statement, used to create a database object, or an ALTER TABLE statement, used to alter a database object. 

Incorrect Answers A:The DELETE command is data-manipulation language (DML) command and it does not complete a transaction. B:The DESCRIBE command is internal SQL*Plus command and it has nothing to do with completion a transaction. 

C: ROLLBACK is not used to commit or complete a transaction, it is used to undo a transaction F:SELECT command is used to retrieve data. It does not complete a transaction. 

OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 281-282 Chapter 3: Advanced Data Selection in Oracle 

Q15. - (Topic 1) 

Which two statements are true about constraints? (Choose two.) 

A. The UNIQUE constraint does not permit a null value for the column. 

B. A UNIQUE index gets created for columns with PRIMARY KEY and UNIQUE constraints. 

C. The PRIMARY KEY and FOREIGN KEY constraints create a UNIQUE index. 

D. The NOT NULL constraint ensures that null values are not permitted for the column. 

Answer: B,D 

Explanation: 

B: A unique constraint can contain null values because null values cannot be compared to anything. 

D: The NOT NULL constraint ensure that null value are not permitted for the column 

Incorrect Answer: Astatement is not true Cstatement is not true 

Refer: Introduction to Oracle9i: SQL, Oracle University Study Guide, 10-9 

START 1Z0-051 EXAM