1Z0-051 Premium Bundle

1Z0-051 Premium Bundle

Oracle Database: SQL Fundamentals I Certification Exam

4.5 
(27570 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
November 5, 2024Last update

Oracle 1Z0-051 Free Practice Questions

Q1. - (Topic 1) 

View the Exhibit and examine the description for the PRODUCTS and SALES table. 

PROD_ID is a primary key in the PRODUCTS table and foreign key in the SALES table. You want to remove all the rows from the PRODUCTS table for which no sale was done for the last three years. Which is the valid DELETE statement? 

A. 

DELETE FROM products WHERE prod_id = (SELECT prod_id FROM sales WHERE time_id - 3*365 = SYSDATE ); 

B. 

DELETE FROM products WHERE prod_id = (SELECT prod_id FROM sales WHERE SYSDATE >= time_id - 3*365 ); 

C. 

DELETE FROM products WHERE prod_id IN (SELECT prod_id FROM sales WHERE SYSDATE - 3*365 >= time_id); 

D. 

DELETE FROM products WHERE prod_id IN (SELECT prod_id FROM sales WHERE time_id >= SYSDATE - 3*365 ); 

Answer:

Q2. - (Topic 1) 

The SQL statements executed in a user session as follows: Exhibit: 

Which two statements describe the consequence of issuing the ROLLBACK TO SAVE POINT a command in the session? (Choose two.) 

A. Both the DELETE statements and the UPDATE statement are rolled back 

B. The rollback generates an error 

C. Only the DELETE statements are rolled back 

D. Only the seconds DELETE statement is rolled back 

E. No SQL statements are rolled back 

Answer: B,E 

Q3. - (Topic 1) 

View the Exhibit and examine the structure of the CUSTOMERS table .Which statement would display the highest credit limit available in each income level in each city in the CUSTOMERS table? 

A. SELECT cust_city, cust_income_level, MAX(cust_credit_limit ) FROM customers GROUP BY cust_city, cust_income_level, cust_credit_limit; 

B. SELECT cust_city, cust_income_level, MAX(cust_credit_limit) FROM customers GROUP BY cust_city, cust_income_level; 

C. SELECT cust_city, cust_income_level, MAX(cust_credit_limit) FROM customers GROUP BY cust_credit_limit, cust_income_level, cust_city ; 

D. SELECT cust_city, cust_income_level, MAX(cust_credit_limit) FROM customers GROUP BY cust_city, cust_income_level, MAX(cust_credit_limit); 

Answer:

Q4. - (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. 

Q5. - (Topic 1) 

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

A. A constraint can be disabled even if the constraint column contains data 

B. A constraint is enforced only for the INSERT operation on a table 

C. A foreign key cannot contain NULL values 

D. All constraints can be defined at the column level as well as the table level 

E. A columns with the UNIQUE constraint can contain NULL values 

Answer: A,E 

Q6. - (Topic 1) 

View the Exhibits and examine the structures of the PROMOTIONS and SALES tables. 

Evaluate the following SQL statements: 

Which statement is true regarding the output of the above query? 

A. It gives details of product IDs that have been sold irrespective of whether they had a 

promo or not 

B. It gives the details of promos for which there have been no sales 

C. It gives the details of promos for which there have been sales 

D. It gives details of all promos irrespective of whether they have resulted in a sale or not 

Answer:

Q7. - (Topic 2) 

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

A. A table can have only one primary key and one foreign key. 

B. A table can have only one primary key but multiple foreign keys. 

C. Only the primary key can be defined at the column and table levels. 

D. The foreign key and parent table primary key must have the same name. 

E. Both primary key and foreign key constraints can be defined at both column and table 

levels. 

Answer: B,E 

Q8. - (Topic 1) 

Exhibit contains the structure of PRODUCTS table: 

Evaluate the following query: 

What would be the outcome of executing the above SQL statement? 

A. It produces an error 

B. It shows the names of products whose list price is the second highest in the table. 

C. It shown the names of all products whose list price is less than the maximum list price 

D. It shows the names of all products in the table 

Answer:

Q9. - (Topic 2) 

Which three statements are true regarding subqueries? (Choose three.) 

A. Subqueries can contain GROUP BY and ORDER BY clauses. 

B. Main query and subquery can get data from different tables. 

C. Main query and subquery must get data from the same tables. 

D. Subqueries can contain ORDER BY but not the GROUP BY clause. 

E. Only one column or expression can be compared between the main query and subquery. 

F. Multiple columns or expressions can be compared between the main query and subquery. 

Answer: A,B,F 

Explanation: 

SUBQUERIES can be used in the SELECT list and in the FROM, WHERE, and HAVING 

clauses of a query. 

A subquery can have any of the usual clauses for selection and projection. The following 

are required clauses: 

A SELECT list 

A FROM clause 

The following are optional clauses: WHERE GROUP BY HAVING 

The subquery (or subqueries) within a statement must be executed before the parent query that calls it, in order that the results of the subquery can be passed to the parent. 

Q10. - (Topic 2) 

View the Exhibit and examine the structure of CUSTOMERS table. Evaluate the following query: 

Which statement is true regarding the above query? 

A. It executes successfully. 

B. It produces an error because the condition on the CUST_CITY column is not valid. 

C. It produces an error because the condition on the CUST_FIRST_NAME column is not valid. 

D. It produces an error because conditions on the CUST_CREDIT_LIMIT column are not valid. 

Answer:

Q11. - (Topic 1) 

You need to calculate the number of days from 1st Jan 2007 till date: 

Dates are stored in the default format of dd-mm-rr. 

Which two SQL statements would give the required output? (Choose two.) 

A. SELECT SYSDATE - TO_DATE('01/JANUARY/2007') FROM DUAL; 

B. SELECT TO_DATE(SYSDATE,'DD/MONTH/YYYY')-'01/JANUARY/2007' FROM DUAL; 

C. SELECT SYSDATE - TO_DATE('01-JANUARY-2007') FROM DUAL 

D. SELECT SYSDATE - '01-JAN-2007' FROM DUAL 

E. SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY')-'01-JAN-2007' FROM DUAL; 

Answer: A,C 

Q12. - (Topic 2) 

Which two statements are true regarding subqueries? (Choose two.) 

A. A subquery can retrieve zero or more rows. 

B. Only two subqueries can be placed at one level. 

C. A subquery can be used only in SQL query statements. 

D. A subquery can appear on either side of a comparison operator. 

E. There is no limit on the number of subquery levels in the WHERE clause of a SELECT statement. 

Answer: A,D 

Explanation: 

Using a Subquery to Solve a Problem Suppose you want to write a query to find out who earns a salary greater than Abel’s salary. To solve this problem, you need two queries: one to find how much Abel earns, and a second query to find who earns more than that amount. You can solve this problem by combining the two queries, placing one query inside the other query. The inner query (or subquery) returns a value that is used by the outer query (or main query). Using a subquery is equivalent to performing two sequential queries and using the result of the first query as the search value in the second query. Subquery Syntax A subquery is a SELECT statement that is embedded in the clause of another SELECT statement. You can build powerful statements out of simple ones by using subqueries. They can be very useful when you need to select rows from a table with a condition that depends on the data in the table itself. You can place the subquery in a number of SQL clauses, including the following: WHERE clause HAVING clause FROM clause In the syntax: operator includes a comparison condition such as >, =, or IN Note: Comparison conditions fall into two classes: single-row operators (>, =, >=, <, <>, <=) and multiple-row operators (IN, ANY, ALL, EXISTS). The subquery is often referred to as a nested SELECT, sub-SELECT, or inner SELECT statement. The subquery generally executes first, and its output is used to complete the query condition for the main (or outer) query. Guidelines for Using Subqueries Enclose subqueries in parentheses. Place subqueries on the right side of the comparison condition for readability. (However, the subquery can appear on either side of the comparison operator.) Use single-row operators with single-row subqueries and multiple-row operators with multiple-row subqueries. 

Subqueries can be nested to an unlimited depth in a FROM clause but to “only” 255 levels in a WHERE clause. They can be used in the SELECT list and in the FROM, WHERE, and HAVING clauses of a query. 

Q13. - (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. 

Q14. - (Topic 2) 

Examine the structure of the TRANSACTIONS table: 

Name Null Type 

TRANS_ID NOT NULL NUMBER(3) 

CUST_NAME VARCHAR2(30) TRANS_DATE DATE TRANS_AMT NUMBER(10,2) 

You want to display the transaction date and specify whether it is a weekday or weekend. Evaluate the following two queries: 

Which statement is true regarding the above queries? 

A. Both give wrong results. 

B. Both give the correct result. 

C. Only the first query gives the correct result. 

D. Only the second query gives the correct result. 

Answer:

Explanation: 

Range Conditions Using the BETWEEN Operator Use the BETWEEN operator to display rows based on a range of values: SELECT last_name, salary FROM employees WHERE salary BETWEEN 2500 AND 3500; Range Conditions Using the BETWEEN Operator You can display rows based on a range of values using the BETWEEN operator. The range that you specify contains a lower limit and an upper limit. The SELECT statement in the slide returns rows from the EMPLOYEES table for any employee whose salary is between $2,500 and $3,500. Values that are specified with the BETWEEN operator are inclusive. However, you must specify the lower limit first. You can also use the BETWEEN operator on character values: SELECT last_name FROM employees WHERE last_name BETWEEN 'King' AND 'Smith' 

Q15. - (Topic 2) 

Which two statements are true regarding tables? (Choose two.) 

A. A table name can be of any length. 

B. A table can have any number of columns. 

C. A column that has a DEFAULT value cannot store null values. 

D. A table 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 in different schemas in the same database. 

Answer: E,F 

Explanation: 

Synonyms Synonyms are database objects that enable you to call a table by another name. You can create synonyms to give an alternative name to a table. 

START 1Z0-051 EXAM