1Z0-051 Premium Bundle

1Z0-051 Premium Bundle

Oracle Database: SQL Fundamentals I Certification Exam

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

Oracle 1Z0-051 Free Practice Questions

Q1. - (Topic 1) 

Evaluate the following SQL commands: 

The command to create a table fails. Identify the reason for the SQL statement failure? 

(Choose all that apply.) 

A. You cannot use SYSDATE in the condition of a CHECK constraint. 

B. You cannot use the BETWEEN clause in the condition of a CHECK constraint. 

C. You cannot use the NEXTVAL sequence value as a DEFAULT value for a column. 

D. You cannot use ORD_NO and ITEM_NO columns as a composite primary key because ORD NO is also the FOREIGN KEY. 

Answer: A,C 

Explanation: 

CHECK Constraint The CHECK constraint defines a condition that each row must satisfy. The condition can use the same constructs as the query conditions, with the following exceptions: References to the CURRVAL, NEXTVAL, LEVEL, and ROWNUM pseudocolumns Calls to SYSDATE, UID, USER, and USERENV functions Queries that refer to other values in other rows A single column can have multiple CHECK constraints that refer to the column in its 

definition. 

There is no limit to the number of CHECK constraints that you can define on a column. 

CHECK constraints can be defined at the column level or table level. 

CREATE TABLE employees 

(... 

salary NUMBER(8,2) CONSTRAINT emp_salary_min 

CHECK (salary > 0), 

Q2. - (Topic 2) 

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 

Q3. - (Topic 2) 

Examine the structure of the EMP_DEPT_VU view: 

Which SQL statement produces an error? 

A. SELECT * 

FROM emp_dept_vu; 

B. SELECT department_id, SUM(salary) 

FROM emp_dept_vu 

GROUP BY department_id; 

C. SELECT department_id, job_id, AVG(salary) 

FROM emp_dept_vu 

GROUP BY department_id, job_id; 

D. SELECT job_id, SUM(salary) 

FROM emp_dept_vu 

WHERE department_id IN (10,20) 

GROUP BY job_id 

HAVING SUM(salary) > 20000; 

E. None of the statements produce an error; all are valid. 

Answer:

Explanation: Explanation: None of the statements produce an error. Incorrect Answer: AStatement will not cause error BStatement will not cause error CStatement will not cause error DStatement will not cause error 

Q4. - (Topic 1) 

The CUSTOMERS table has the following structure: Exhibit: 

You need to write a query that does the following task: 

Display the first name and tax amount of the customers. Tax is 5% of their credit limit 

Only those customers whose income level has a value should be considered 

Customers whose tax amount is null should not be considered 

Which statement accomplishes all the required tasks? 

A. 

SELECT cust_first_name, cust_credit_limit * .05 AS TAX_AMOUNT FROM customers WHERE cust_income_level IS NOT NULL AND tax_amount IS NOT NULL; 

B. 

SELECT cust_first_name, cust_credit_limit * .05 AS TAX_AMOUNT FROM customers WHERE cust_income_level IS NOT NULL AND cust_credit_limit IS NOT NULL; 

C. 

SELECT cust_first_name, cust_credit_limit * .05 AS TAX_AMOUNT FROM customers WHERE cust_income_level <> NULL AND tax_amount <> NULL; 

D. 

SELECT cust_first_name, cust_credit_limit * .05 AS TAX_AMOUNT FROM customers WHERE (cust_income_level,tax_amount) IS NOT NULL; 

Answer:

Q5. - (Topic 1) 

Which three statements are true regarding sub queries? (Choose three.) 

A. Multiple columns or expressions can be compared between the main query and sub query 

B. Sub queries can contain GROUP BY and ORDER BY clauses 

C. Only one column or expression can be compared between the main query and subqeury 

D. Main query and sub query can get data from different tables 

E. Main query and sub query must get data from the same tables 

F. Sub queries can contain ORDER BY but not the GROUP BY clause 

Answer: A,B,D 

Q6. - (Topic 1) 

Which three statements are true about multiple-row sub queries? (Choose three.) 

A. They can contain a subquery within a sub query. 

B. They can return multiple columns as well as rows. 

C. They cannot contain a sub query within a sub query. 

D. They can return only one column but multiple rows. 

E. They can contain group functions and GROUP BY and HAVING clauses. 

F. They can contain group functions and the GROUP BY clause, but not the HAVING clause. 

Answer: A,B,E 

Q7. - (Topic 2) 

Evaluate the SQL statement 

DROP TABLE DEPT: 

Which four statements are true of the SQL statement? (Choose four) 

A. You cannot roll back this statement. 

B. All pending transactions are committed. 

C. All views based on the DEPT table are deleted. 

D. All indexes based on the DEPT table are dropped. 

E. All data in the table is deleted, and the table structure is also deleted. 

F. All data in the table is deleted, but the structure of the table is retained. 

G. All synonyms based on the DEPT table are deleted. 

Answer: A,B,D,E 

Explanation: 

You cannot roll back DROP TABLE statement. All pending transactions related on this 

table are committed. If the table is dropped, Oracle automatically drops any index, trigger 

and constraint associated with the table as well. All data in the table is deleted, and the 

table structure is also deleted. 

Incorrect Answers 

C:All views based on the DEPT table become invalid, but they are not deleted. 

F:All data in the table is deleted, and the table structure is also deleted. Command 

TRUNCATE deletes all data in the table, but does not delete the structure of the table. 

G:All synonyms based on the DEPT table are not deleted after dropping the table. 

OCP Introduction to Oracle 9i: SQL Exam Guide, Jason Couchman, p. 225 Chapter 5: Creating Oracle Database Objects 

Q8. - (Topic 2) 

View the Exhibits and examine the structures of the CUSTOMERS, SALES, and COUNTRIES tables. 

You need to generate a report that shows all country names, with corresponding customers (if any) and sales details (if any), for all customers. 

Which FROM clause gives the required result? 

A. FROM sales JOIN customers USING (cust_id) FULL OUTER JOIN countries USING (country_id); 

B. FROM sales JOIN customers USING (cust_id) RIGHT OUTER JOIN countries USING (country_id); 

C. FROM customers LEFT OUTER JOIN sales USING (cust_id) RIGHT OUTER JOIN countries USING (country_id); 

D. FROM customers LEFT OUTER JOIN sales USING (cust_id) LEFT OUTER JOIN countries USING (country_id); 

Answer:

Q9. - (Topic 2) 

View the exhibit and examine the description for the SALES and CHANNELS tables. 

You issued the following SQL statement to insert a row in the SALES table: 

INSERT INTO sales VALUES (23, 2300, SYSDATE, (SELECT channel_id FROM channels WHERE channel_desc='Direct Sales'), 12, 1, 500); 

Which statement is true regarding the execution of the above statement? 

A. The statement will execute and the new row will be inserted in the SALES table. 

B. The statement will fail because subquery cannot be used in the VALUES clause. 

C. The statement will fail because the VALUES clause is not required with subquery. 

D. The statement will fail because subquery in the VALUES clause is not enclosed with in single quotation marks. 

Answer:

Q10. - (Topic 1) 

Examine the structure and data in the PRIC E_LIST table: Name Null? Type 

PROD_D NOT NULL NUMBER(3) 

PROD_PRICE VARCHAR2(10) 

PROD_ID PROD PRICE 

100 $234.55 

101 $6,509.75 

102 $1,234 

in the same format as the PROD_PRICE. Which SQL statement would give the required result? 

A. SELECT TO_CHAR(prod_price* .25.'$99.999.99') FROM PRICEJLIST: 

B. SELECT TO_CHAR(TO_NUMBER(prod_price)* .25.'$99.999.00') FROM PRICE_LIST; 

C. SELECT TO_CRAR(TO_NUMBER(prod_price.'S99.999.99')* .25.'$99.999.00') FROM PRICE_LIST: 

D. SELECT TO_NUMBER(TO_NUMBER(prod_price.,$99.999.99')* .25/$99.999.00') FROM PRICE_LIST: 

Answer:

Q11. - (Topic 1) 

The STUDENT_GRADES table has these columns: 

STUDENT_IDNUMBER(12) 

SEMESTER_ENDDATE 

GPANUMBER(4,3) 

The registrar has asked for a report on the average grade point average (GPA), sorted from the highest grade point average to each semester, starting from the earliest date. 

Which statement accomplish this? 

A. 

SELECT student_id, semester_end, gpa FROM student_grades ORDER BY semester_end DESC, gpa DESC; 

B. 

SELECT student_id, semester_end, gpa FROM student_grades ORDER BY semester_end, gpa ASC 

C. 

SELECT student_id, semester_end, gpa FROM student_grades ORDER BY gpa DESC, semester_end ASC; 

D. 

SELECT student_id, semester_end, gpa FROM student_grades ORDER BY gpa DESC, semester_end DESC; 

E. 

SELECT student_id, semester_end, gpa FROM student_grades ORDER BY gpa DESC, semester_end ASC; 

F. 

SELECT student_id,semester_end,gpa FROM student_grades ORDER BY semester_end,gpa DESC 

Answer:

Q12. - (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:

Q13. - (Topic 2) 

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

A. A foreign key cannot contain NULL values. 

B. A column with the UNIQUE constraint can contain NULL values. 

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

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

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

Answer: B,D 

Explanation: 

Including Constraints 

Constraints enforce rules at the table level. 

Constraints prevent the deletion of a table if there are dependencies. 

The following constraint types are valid: 

– 

NOT NULL 

– 

UNIQUE 

– 

PRIMARY KEY 

– 

FOREIGN KEY 

– 

CHECK 

Q14. - (Topic 2) 

Examine the structure of the PROMOS table: 

You want to display the list of promo names with the message 'Same Day' for promos that started and ended on the same day. 

Which query gives the correct output? 

A. SELECT promo_name, NVL(NULLIF(promo_start_date, promo_end_date), 'Same Day') 

FROM promos; 

B. SELECT promo_name, NVL(TRUNC(promo_end_date - promo_start_date), 'Same 

Day') FROM promos; 

C. SELECT promo_name, NVL2(TO_CHAR(TRUNC(promo_end_date-promo_start_date)), 

NULL,'Same Day') 

FROM promos; 

D. SELECT promo_name, DECODE((NULLIF(promo_start_date, promo_end_date)), 

NULL,'Same day') FROM promos; 

Answer:

Explanation: 

The NULLIF Function The NULLIF function tests two terms for equality. If they are equal the function returns a null, else it returns the first of the two terms tested. The NULLIF function takes two mandatory parameters of any data type. The syntax is NULLIF(ifunequal, comparison_term), where the parameters ifunequal and comparison_term are compared. If they are identical, then NULL is returned. If they differ, the ifunequal parameter is returned ANSWER A - date and String incompatibl;a datatypes for NVL function The Date TRUNC Function The date TRUNC function performs a truncation operation on a date value based on a specified date precision format. The date TRUNC function takes one mandatory and one optional parameter. Its syntax is TRUNC(source date, [date precision format]). The source date parameter represents any value that can be implicitly converted into a date item. The date precision format parameter specifies the degree of truncation and is optional. If it is absent, the default degree of truncation is day. This means that any time component 

Q15. - (Topic 1) 

You work as a database administrator at ABC.com. You study the exhibit carefully. 

Exhibit: 

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

A. 

UPDATE promotions SET promo_cost = promo_cost+ 100 WHERE TO_CHAR(promo_end_date, 'yyyy') > '2000' 

B. 

SELECT promo_begin_date FROM promotions WHERE TO_CHAR(promo_begin_date,'mon dd yy')='jul 01 98' 

C. 

UPDATE promotions SET promo_cost = promo_cost+ 100 WHERE promo_end_date > TO_DATE(SUBSTR('01-JAN-2000',8)); 

D. 

SELECT TO_CHAR(promo_begin_date,'dd/month') FROM promotions 

WHERE promo_begin_date IN (TO_DATE('JUN 01 98'), TO_DATE('JUL 01 98')); 

Answer: A,B 

START 1Z0-051 EXAM